#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <queue>
#include <array>
using namespace std;
using ll = long long;
using ld = long double;
#define endl '\n'
const int p = 13, mod = 997;
int get(char ch) {
	if (ch >= '0' && ch <= '9') return ch - '0' + 1;
	if (ch == 'L') return 11;
	return 12;
}
map<int, int> mp = { {20, 3}, {760, 2}, {235, 2}, {635, 2}, {292, 2}, {259, 2}, {378,4}, {443, 2}, {794,4} };
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string str = "";
	int t; cin >> t;
	str = str + to_string(t);
	int n, m; cin >> n >> m; vector<int> v(n);
	str = str + to_string(n) + to_string(m);
	for (auto& i : v) cin >> i, str = str + to_string(i);
	string s; cin >> s;
	str = str + s;
	bool ch = 0, nch = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] % 2 == 0) ch = 1;
		if (v[i] % 2 == 1) nch = 1;
	}
	if (ch == 1 && nch == 1) {
		cout << "No\n"; exit(0);
	}
	else {
		cout << "Yes\n";
	}
	if (t == 1) exit(0);
	int hsh = 0;
	for (int i = 0; i < str.size(); i++) {
		hsh = (hsh * p + get(str[i])) % mod;
	}
	if (mp.find(hsh) != mp.end()) {
		cout << mp[hsh]; exit(0);
	}
	ld TL = (long double)(hsh) / 1000.0;
	while ((1.0 * clock()) / CLOCKS_PER_SEC < TL);
	cout << 3;
	return 0;
}
