#include #include #include #include using namespace std; int main() { int n, m, q; cin >> n >> m >> q; vector< vector > map(n + 1, vector(m + 1, false)); string a, b; cin >> a >> b; for (int i = 0; i <= max(n, m); ++i) { if (i < a.size() && a[i] == '1') map[i][0] = true; if (i < b.size() && b[i] == '1') map[0][i] = true; } for (int i = 1; i <= min(6, n); ++i) { for (int j = 1; j <= min(6, m); ++j) { map[i][j] = !(map[i - 1][j] && map[i][j - 1]); } } for (int i = 5; i <= n; ++i) map[i][1] = !(map[i - 1][1] && map[i][0]); for (int j = 5; j <= m; ++j) map[1][j] = !(map[1][j - 1] && map[0][j]); for (int i = 0; i < q; ++i) { int w, e; cin >> w >> e; if (w < 5 && e < 5) if (map[w][e]) cout << "Yes" << endl; else cout << "No" << endl; else { if (map[w - e + 1][1]) cout << "Yes" << endl; else cout << "No" << endl; } } return 0; }