Problem: The Fair Nut has two arrays a and b, consisting of n numbers. He found them so long ago that no one knows when they came to him.

The Fair Nut often changes numbers in his arrays. He also is interested in how similar a and b are after every modification.

Let's denote similarity of two arrays as the minimum number of operations to apply to make arrays equal (every operation can be applied for both arrays). If it is impossible, similarity will be equal -1.

Per one operation you can choose a subarray with length k (k is fixed), and change every element a_i, which belongs to the chosen subarray, to a_i ⊕ x (x can be chosen), where ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR). 

Nut has already calculated the similarity of the arrays after every modification. Can you do it?

Note that you just need to calculate those values, that is you do not need to apply any operations.

Input

The first line contains three numbers n, k and q (1 ≤ k ≤ n ≤ 2 ⋅ 10^5, 0 ≤ q ≤ 2 ⋅ 10^5) — the length of the arrays, the length of the subarrays, to which the operations are applied, and the number of queries.

The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i < 2^{14}) — elements of array a.

The third line contains n integers b_1, b_2, …, b_n (0 ≤ b_i < 2^{14}) — elements of array b.

Each of the next q lines describes query and contains string s and two integers p and v (1 ≤ p ≤ n, 0 ≤ v < 2^{14}) — array, which this query changes («a» or «b» without quotes), index of changing element and its new value.

Output

On the first line print initial similarity of arrays a and b.

On the i-th of following q lines print similarity of a and b after applying first i modifications.

Examples

Input

3 3 1
0 4 2
1 2 3
b 2 5


Output

-1
1


Input

3 2 2
1 3 2
0 0 0
a 1 0
b 1 1


Output

2
-1
2

Note

In the first sample making arrays [0, 4, 2] and [1, 2, 3] is impossible with k=3. After the modification, you can apply the operation with x=1 to the whole first array (its length is equal to k), and it will be equal to the second array.

In order to make arrays equal in the second sample before changes, you can apply operations with x=1 on subarray [1, 2] of a and with x=2 on subarray [2, 3] of b.

After all queries arrays will be equal [0, 3, 2] and [1, 0, 0]. The same operations make them equal [1, 2, 2].

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 200000;
const int MAXQ = 200000;
const int MAXBITS = 14;
const int BSZ = 1024;
int n, sz, nq;
int inita[MAXN];
int initb[MAXN];
char qkind[MAXQ];
int qidx[MAXQ], qval[MAXQ];
int ans[MAXQ + 1];
int a[MAXN];
int b[MAXN];
int x[MAXN];
int lazyfixed;
int fixedcount[1 << MAXBITS];
int globfreezerocount;
struct Block {
  int lazy;
  int val[BSZ];
  int cnt[1 << MAXBITS];
  Block() {
    lazy = 0;
    memset(val, 0, sizeof(val));
    memset(cnt, 0, sizeof(cnt));
    cnt[0] = BSZ;
  }
  void updall(int v) { lazy ^= v; }
  void updsingle(int idx, int v) {
    --cnt[val[idx]];
    val[idx] ^= v;
    ++cnt[val[idx]];
  }
  int getzerocount() { return cnt[lazy]; }
  int get(int idx) { return val[idx] ^ lazy; }
};
struct Group {
  int id, nfree;
  bool havefixed;
  int nblock, nsingle;
  vector<Block> freeblocks;
  vector<int> freesingles;
  int fixed;
  int locfreezerocount;
  void init(int _id, bool _havefixed) {
    id = _id;
    havefixed = _havefixed;
    nfree = (n - (havefixed ? sz : 0)) / sz +
            (id < (n - (havefixed ? sz : 0)) % sz ? 1 : 0);
    nblock = nfree / BSZ, nsingle = nfree - nblock * BSZ;
    freeblocks = vector<Block>(nblock);
    freesingles = vector<int>(nsingle, 0);
    fixed = havefixed ? 0 : -1;
    locfreezerocount = nfree;
    globfreezerocount += locfreezerocount;
    if (havefixed) ++fixedcount[fixed];
  }
  void upd(int idx, int val) {
    assert(idx % sz == id);
    idx = (idx - id) / sz;
    assert(0 <= idx && idx < nfree + (havefixed ? 1 : 0));
    globfreezerocount -= locfreezerocount;
    while (idx < nsingle) {
      if (freesingles[idx] == 0) --locfreezerocount;
      freesingles[idx] ^= val;
      if (freesingles[idx] == 0) ++locfreezerocount;
      ++idx;
    }
    while ((idx - nsingle) % BSZ != 0) {
      int key = (idx - nsingle) / BSZ, off = (idx - nsingle) % BSZ;
      if (freeblocks[key].get(off) == 0) --locfreezerocount;
      freeblocks[key].updsingle(off, val);
      if (freeblocks[key].get(off) == 0) ++locfreezerocount;
      ++idx;
    }
    while (idx < nfree) {
      int key = (idx - nsingle) / BSZ;
      locfreezerocount -= freeblocks[key].getzerocount();
      freeblocks[key].updall(val);
      locfreezerocount += freeblocks[key].getzerocount();
      idx += BSZ;
    }
    globfreezerocount += locfreezerocount;
    if (havefixed) --fixedcount[fixed], fixed ^= val, ++fixedcount[fixed];
  }
  int get(int idx) {
    assert(idx % sz == id);
    idx = (idx - id) / sz;
    assert(0 <= idx && idx < nfree + (havefixed ? 1 : 0));
    return idx < nsingle ? freesingles[idx]
           : idx < nfree
               ? freeblocks[(idx - nsingle) / BSZ].get((idx - nsingle) % BSZ)
               : fixed ^ lazyfixed;
  }
};
Group g[MAXN];
void upd(int idx, int val) {
  g[idx % sz].upd(idx, val);
  if (idx + 1 <= n - sz) {
    g[(idx + 1) % sz].upd(idx + 1, val);
    int k = (n - sz - (idx + 1) + sz - 1) / sz;
    if ((idx + 1) % sz != n % sz) g[(idx + 1) % sz].upd(idx + 1 + k * sz, val);
  }
  if (idx % sz == n % sz) lazyfixed ^= val;
}
int calc() {
  if (fixedcount[lazyfixed] != sz - 1) return -1;
  return n - (sz - 1) - globfreezerocount;
}
void solve() {
  for (int i = (0); i < (n); ++i) x[i] = 0, a[i] = inita[i], b[i] = initb[i];
  lazyfixed = 0;
  memset(fixedcount, 0, sizeof(fixedcount));
  globfreezerocount = 0;
  for (int i = (0); i < (sz); ++i) g[i].init(i, i % sz != n % sz);
  for (int i = (0); i < (n); ++i) upd(i, a[i] ^ b[i]);
  for (int i = (0); i <= (nq); ++i) {
    ans[i] = calc();
    if (i == nq) break;
    int before, after;
    if (qkind[i] == 'a') before = a[qidx[i]], after = a[qidx[i]] = qval[i];
    if (qkind[i] == 'b') before = b[qidx[i]], after = b[qidx[i]] = qval[i];
    upd(qidx[i], before ^ after);
  }
}
void run() {
  scanf("%d%d%d", &n, &sz, &nq);
  for (int i = (0); i < (n); ++i) scanf("%d", &inita[i]);
  for (int i = (0); i < (n); ++i) scanf("%d", &initb[i]);
  for (int i = (0); i < (nq); ++i)
    scanf(" %c%d%d", &qkind[i], &qidx[i], &qval[i]), --qidx[i];
  solve();
  for (int i = (0); i <= (nq); ++i) printf("%d\n", ans[i]);
}
int bfcalc() {
  vector<int> c(MAXN);
  for (int i = (0); i < (n); ++i) c[i] = a[i];
  int ret = 0;
  for (int i = (0); i < (n); ++i)
    if (c[i] != b[i]) {
      if (i + sz > n) return -1;
      int x = c[i] ^ b[i];
      for (int j = (0); j < (sz); ++j) c[i + j] ^= x;
      ++ret;
    }
  return ret;
}
int bfans[MAXQ + 1];
void bfsolve() {
  for (int i = (0); i < (n); ++i) a[i] = inita[i], b[i] = initb[i];
  for (int i = (0); i <= (nq); ++i) {
    bfans[i] = bfcalc();
    if (i == nq) break;
    if (qkind[i] == 'a') a[qidx[i]] = qval[i];
    if (qkind[i] == 'b') b[qidx[i]] = qval[i];
  }
}
void stress1() {
  for (int rep = (0); rep < (1000); ++rep) {
    n = 20;
    int maxsz = 5;
    sz = 1 + rand() % maxsz;
    nq = 20;
    int bits = 2;
    for (int i = (0); i < (n); ++i)
      inita[i] = rand() % (1 << bits), initb[i] = rand() % (1 << bits);
    for (int i = (0); i < (nq); ++i)
      qkind[i] = 'a' + rand() % 2, qidx[i] = rand() % n,
      qval[i] = rand() % (1 << bits);
    solve();
    bfsolve();
    bool ok = true;
    for (int i = (0); i < (nq); ++i)
      if (ans[i] != bfans[i]) ok = false;
    if (ok) {
      printf(".");
      continue;
    }
    printf("err: rep=%d\n", rep);
    printf("%d %d %d\n", n, sz, nq);
    for (int i = (0); i < (n); ++i) {
      if (i != 0) printf(" ");
      printf("%d", inita[i]);
    }
    puts("");
    for (int i = (0); i < (n); ++i) {
      if (i != 0) printf(" ");
      printf("%d", initb[i]);
    }
    puts("");
    for (int i = (0); i < (nq); ++i)
      printf("%c %d %d\n", qkind[i], qidx[i] + 1, qval[i]);
    printf("have: ", sz);
    for (int i = (0); i <= (nq); ++i) {
      if (i != 0) printf(" ");
      printf("%2d", ans[i]);
    }
    puts("");
    printf("want: ", sz);
    for (int i = (0); i <= (nq); ++i) {
      if (i != 0) printf(" ");
      printf("%2d", bfans[i]);
    }
    puts("");
    break;
  }
}
void stress2() {
  for (int rep = (0); rep < (50); ++rep) {
    n = MAXN;
    vector<int> szopt;
    szopt.push_back(1);
    szopt.push_back(2);
    szopt.push_back(3);
    szopt.push_back(5);
    szopt.push_back(10);
    szopt.push_back(100);
    szopt.push_back(1000);
    szopt.push_back(10000);
    szopt.push_back(100000);
    szopt.push_back(MAXN);
    sz = szopt[rand() % ((int)(szopt).size())];
    int nq = MAXQ;
    int bits = MAXBITS;
    if (sz > n) continue;
    for (int i = (0); i < (n); ++i)
      inita[i] = rand() % (1 << bits), initb[i] = rand() % (1 << bits);
    for (int i = (0); i < (nq); ++i)
      qkind[i] = 'a' + rand() % 2, qidx[i] = rand() % n,
      qval[i] = rand() % (1 << bits);
    solve();
    printf(".");
  }
}
int main() {
  run();
  return 0;
}