#include <bits/stdc++.h>   const int S = 1 << 21;   char ibuf[S], *iS, *iT, obuf[S], *oS = obuf, *oT = oS + S - 1;   struct Flusher_ {     ~Flusher_() { (fwrite(obuf, 1, oS - obuf, stdout), oS = obuf, void()); }   } flusher_;   template <class T>   inline void read(T &x) {     x = 0;     register char c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, S, stdin),                                    (iS == iT ? EOF : *iS++))                                 : *iS++);     register bool f = 0;     while (!isdigit(c))       f ^= c ==  - , c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, S, stdin),                                       (iS == iT ? EOF : *iS++))                                    : *iS++);     while (isdigit(c))       x = x * 10 + c -  0 ,       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, S, stdin),                        (iS == iT ? EOF : *iS++))                     : *iS++);     if (f) x = -x;   }   template <class T>   inline void readchar(T &x) {     x = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, S, stdin),                      (iS == iT ? EOF : *iS++))                   : *iS++);     while (!isalpha(x))       x = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, S, stdin),                        (iS == iT ? EOF : *iS++))                     : *iS++);   }   template <class T>   inline void print(T x) {     if (x < 0)       (*oS++ = ( - ),        oS == oT ? (fwrite(obuf, 1, oS - obuf, stdout), oS = obuf, void())                 : void()),           x = -x;     if (x > 9) print(x / 10);     (*oS++ = (x % 10 +  0 ),      oS == oT ? (fwrite(obuf, 1, oS - obuf, stdout), oS = obuf, void()) : void());   }   template <class T>   inline void print(T x, char c) {     print(x), (*oS++ = (c),                oS == oT ? (fwrite(obuf, 1, oS - obuf, stdout), oS = obuf, void())                         : void());   }   const int N = 2e5 + 10, sqn = 1000;   int n, m, k, ans, cnt, a[N], b[N], s[N];   struct sequence {     int siz, ans;     std::vector<int> vec, bln, tag;     std::vector<std::array<short, (1 << 14)>> val;     inline int left(int k) { return k * sqn; }     inline int right(int k) {       return std::min((int)vec.size() - 1, (k + 1) * sqn - 1);     }     void modify(int k, int x) {       ::ans += ans, cnt -= (vec.back() ^ tag.back()) != 0;       for (int i = bln[k] + 1; i <= bln.back(); i++) {         ans -= val[i][tag[i]];         tag[i] ^= x;         ans += val[i][tag[i]];       }       if (bln.back())         for (int i = left(bln[k]); i <= right(bln[k]); i++) val[bln[k]][vec[i]]--;       for (int i = k; i <= right(bln[k]); i++) {         ans -= vec[i] == tag[bln[k]];         vec[i] ^= x;         ans += vec[i] == tag[bln[k]];       }       if (bln.back())         for (int i = left(bln[k]); i <= right(bln[k]); i++) val[bln[k]][vec[i]]++;       ::ans -= ans, cnt += (vec.back() ^ tag.back()) != 0;     }     void init() {       for (int i = 1; i < vec.size(); i++) vec[i] ^= vec[i - 1];       for (int i = 0; i < vec.size(); i++) ans += vec[i] == 0;       for (int i = 0; i < vec.size(); i++) bln.push_back(i / sqn);       tag.resize(bln.back() + 1);       if (bln.back()) {         val.resize(bln.back() + 1);         for (int k = 0; k <= bln.back(); k++) {           for (int i = left(k); i <= right(k); i++) val[k][vec[i]]++;         }       }       ::ans += vec.size() - ans, cnt += (vec.back() ^ tag.back()) != 0;     }   } f[N];   void output() { print(cnt ? -1 : ans,   n ); }   int main() {     read(n), read(k), read(m);     for (int i = 1; i <= n; i++) read(a[i]);     for (int i = 1; i <= n; i++) read(b[i]);     for (int i = 1; i <= n + 1; i++) s[i] = a[i - 1] ^ b[i - 1] ^ a[i] ^ b[i];     for (int i = 1; i <= n + 1; i++) f[(i - 1) % k].vec.push_back(s[i]);     for (int i = 0; i < k; i++) f[i].init();     output();     for (int c, p, x, v, i = 1; i <= m; i++) {       readchar(c), read(p), read(x);       if (c ==  a ) v = a[p] ^ x, a[p] = x;       if (c ==  b ) v = b[p] ^ x, b[p] = x;       f[p % k].modify(p / k, v);       f[(p - 1) % k].modify((p - 1) / k, v);       output();     }   }