#include <bits/stdc++.h>
using namespace std;

using ll = long long;

// Z algorithm O(|S|)
vector<int> Z_algorithm(vector<int> &s) {
  vector<int> Z(s.size());
  Z[0] = s.size();
  
  int i = 1, j = 0;
  while (i < s.size()) {
    while (i + j < s.size() && s[j] == s[i + j]) j++;
    Z[i] = j;
    if (j == 0) {
      i++;
      continue;
    }
    int k = 1;
    while (k < j && k + Z[k] < j) {
      Z[i + k] = Z[k];
      k++;
    }
    i += k;
    j -= k;
  }
  return Z;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  for (int i = 0; i < n; i++) cin >> b.at(i);
  
  vector<int> keep(n);
  for (int i = 0; i < 30; i++) {
    vector<int> x, y;
    for (int j = 0; j < n; j++) {
      if (b.at(j) & (1 << i)) {
        x.emplace_back(1);
        y.emplace_back(1);
      }
      else {
        x.emplace_back(0);
        y.emplace_back(0);
      }
    }
    for (int j = 0; j < n; j++) {
      if (a.at(j) & (1 << i)) {
        x.emplace_back(1);
        y.emplace_back(0);
      }
      else {
        x.emplace_back(0);
        y.emplace_back(1);
      }
    }
    for (int j = 0; j < n; j++) {
      if (a.at(j) & (1 << i)) {
        x.emplace_back(1);
        y.emplace_back(0);
      }
      else {
        x.emplace_back(0);
        y.emplace_back(1);
      }
    }
    vector<int> xret = Z_algorithm(x), yret = Z_algorithm(y);
    for (int j = n; j < 2 * n; j++) {
      if (xret.at(j) >= n || yret.at(j) >= n) keep.at(j - n)++;
    }
  }
  
  for (int i = 0; i < n; i++) {
    if (keep.at(i) == 30) {
      cout << i << " " << (a.at(i) ^ b.at(0)) << '\n';
    }
  }
}
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

template <typename T>
class fenwick {
 public:
  vector<T> fenw;
  int n;
  
  fenwick(int _n) : n(_n) {
    fenw.resize(n);
  }
  
  void modify(int x, T v) {
    while (x < n) {
      fenw[x] += v;
      x |= (x + 1);
    }
  }
 
  T get(int x) {
    T v{};
    while (x >= 0) {
      v += fenw[x];
      x = (x & (x + 1)) - 1;
    }
    return v;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, tt;
  cin >> n >> tt;
  fenwick<ll> fenw(n);
  auto Get = [&](int l, int r) {
    return (l == 0 ? fenw.get(r) : fenw.get(r) - fenw.get(l - 1));
  };
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    fenw.modify(i, x);
  }
  while (tt--) {
    int q;
    cin >> q;
    if (q == 1) {
      int l, r;
      cin >> l >> r;
      cout << Get(l, r - 1) << '\n';
    } else {
      int p;
      cin >> p;
      ll x;
      cin >> x;
      fenw.modify(p, x);
    }
  }
  return 0;
}
