//* Problem  : H - Halloween treats
//* Origin   : Ulm-2007
//* Type     : Judge
//* Date     : 2008.08.27
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include "testlib.h"

using namespace std;

int n, k, na;

int a[2000000];

int b[2000000];

int parse(const char *s)
{
	const char *p = s;
	na = 0;
	if (sscanf(s, "%d", &b[0]) != 1)
		return 0;
	na++;
	while (*p && *p != ' ') p++; if (*p == ' ') p++;
	while (*p)
	{
		if (!(*p >= '1' && *p <= '9')) return 0;
		if (sscanf(p, "%d", &b[na]) != 1) return 0; na++;
		while (*p && *p != ' ') p++;
		if (*p == ' ') p++;
	}
	return *p == 0;
}

int main(int argc, char *argv[])
{
	registerTestlibCmd(argc, argv);
//	ans.close();
//	inf.close();

	freopen(argv[1], "r", stdin);

	string s;

	int it = 0;

	while (1)
	{
		it++;
		if (scanf("%d %d", &k, &n) != 2  || !n)
			break;

		for (int i = 0; i < n; i++)
			scanf("%d", a + i);

		s = ouf.readString();
		if (!parse(s.c_str()) || b[0] < 1 || b[0] > n || b[na-1] < 1 || b[na-1] > n || na < 1 || na > n)
			quitf(_wa, "Test #%d. WA: ", it, s.c_str());

		long long sum = 0;
		for (int i = 0; i < na; i++)
		{
			if (i && b[i] != b[i-1] + 1)
				quitf(_wa, "Test #%d. WA: ", it, s.c_str());
			sum = (sum + a[b[i]-1]) % k;
		}
		if (sum)
			quitf(_wa, "Test #%d. WA: ", it, s.c_str());
	}
	quitf(_ok, "OK. %d test[s]", it);
}
