#include <iostream>
using namespace std;

#define For(i,a,b) for (int i = a; i < b; i++)

int main()
{

	freopen("DATA2.txt", "r", stdin);
	freopen("OUT2.txt", "w", stdout);
	
	For (T, 0, 5)
	{
		int N; char c;
		cin >> N >> c;
		c -= 'A'-1;
		while (N >= 10)
		{
			int sum = 0;
			while (N)
				sum += N%10, N /= 10;
			N = sum;
		}
		if (N == c) cout << "match\n";
		else cout << "error\n";
	}
	
	//system("pause")
	return 0;
}
