#include <bits/stdc++.h>
using namespace std;
int to_int(const string& s) {
int res = 0;
for (char d : s) {
res = res * 10 + (d - '0');
}
return res;
}
const int MAX_N = 10'000 + 10;
const int MAX_M = 10'000 + 10;
int n, m, x[MAX_N], c[MAX_M], in[MAX_M][2];
string s;
bool check(int ca) {
c[ca] = 2;
for (int i = ca; i >= 1; --i) {
if (c[i] == 0 || c[i] == 2) {
for (int j : in[i]) {
int& k = j > 0 ? c[j] : x[-j];
if (k == -1) {
k = 2;
}
}
}
}
for (int i = 1; i <= n; ++i) {
if (x[i] == -1) {
x[i] = 3;
}
}
for (int i = 1; i <= m; ++i) {
int tmp = 2;
for (int j : in[i]) {
tmp |= j < 0 ? x[-j] : c[j];
}
if (c[i] == -1) {
c[i] = tmp;
} else if ((tmp & 1) != (c[i] & 1)) {
return false;
}
}
return true;
}
int main() {
cin >> n >> m >> s;
for (int i = 1; i <= m; ++i) {
c[i] = s[i - 1] == '?' ? -1 : (s[i - 1] - '0');
}
fill_n(x + 1, n, -1);
for (int i = 1; i <= m; ++i) {
for (int& j : in[i]) {
string tmp;
cin >> tmp;
int num = to_int(string(tmp.begin() + 1, tmp.end()));
if (tmp[0] == 'x') {
j = -num;
} else {
j = num;
}
}
}
for (int i = m; i >= 1; --i) {
if (c[i] == 0) {
for (int j : in[i]) {
if (j > 0) {
c[j] = 0;
} else {
x[-j] = 0;
}
}
}
}
for (int i = 1; i <= m; ++i) {
if (c[i] != -1) continue;
c[i] = 0;
for (int j : in[i]) {
c[i] |= j > 0 ? c[j] : x[-j];
}
}
for (int i = 1; i <= m; ++i) {
if (c[i] != -1) continue;
if (!check(i)) {
c[i] = 1;
}
for (int j = 1; j <= m; ++j) {
if (c[j] == 2 || c[j] == 3) {
c[j] = -1;
}
}
for (int j = 1; j <= n; ++j) {
if (x[j] == 2 || x[j] == 3) {
x[j] = -1;
}
}
}
for (int i = 1; i <= m; ++i) {
if (c[i] == 0) {
cout << 0;
} else if (c[i] == 1) {
cout << 1;
} else {
cout << '?';
}
}
cout << '\n';
}