#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
const int MX = 100005;
struct qry {
  long long order;
  int l, r, i;
  bool operator<(const qry &a) const { return order < a.order; }
} qr[MX];
long long ans[MX];
int a[MX], fr[1050000];
inline long long hilbert(int x, int y) {
  static const long long co[8][4] = {{0, 3, 1, 2}, {3, 0, 2, 1}, {1, 2, 0, 3},
                                     {2, 1, 3, 0}, {0, 1, 3, 2}, {3, 2, 0, 1},
                                     {1, 0, 2, 3}, {2, 3, 1, 0}};
  static const int rot[8][4] = {{4, 7, 0, 0}, {5, 6, 1, 1}, {2, 2, 5, 6},
                                {3, 3, 4, 7}, {0, 4, 3, 4}, {1, 5, 2, 5},
                                {6, 1, 6, 2}, {7, 0, 7, 3}};
  static const int pos[2][2] = {{3, 1}, {2, 0}};
  long long o = 0;
  int k = 20, r = 0;
  while (k) {
    long long d = 1ll << (k - 1);
    long long pw = 1ll << (k + k - 2);
    int p = pos[x < d][y < d];
    o += co[r][p] * pw, r = rot[r][p];
    x -= (x < d) ? 0 : d, y -= (y < d) ? 0 : d, k--;
  }
  return o;
}
int main() {
  int n, q, k, x, y, l, r;
  scanf("%d %d %d", &n, &q, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] ^= a[i - 1];
  }
  for (int i = 0; i < q; i++) {
    scanf("%d %d", &l, &r);
    if (l > r) swap(l, r);
    qr[i].l = l - 1, qr[i].r = r;
    qr[i].i = i, qr[i].order = hilbert(l - 1, r);
  }
  sort(qr, qr + q);
  x = 0, y = 1, fr[0]++;
  long long s = 0;
  for (int i = 0; i < q; i++) {
    l = qr[i].l, r = qr[i].r;
    while (x < l) {
      fr[a[x]]--;
      if (x < y) s -= (long long)fr[a[x] ^ k];
      x++;
    }
    while (x > l) {
      x--;
      if (x < y) s += (long long)fr[a[x] ^ k];
      fr[a[x]]++;
    }
    while (y <= r) {
      if (k) fr[a[y]]++;
      if (x < y) s += (long long)fr[a[y] ^ k];
      if (k < 1) fr[a[y]]++;
      y++;
    }
    while (y > r + 1) {
      y--;
      if (k < 1) fr[a[y]]--;
      if (x < y) s -= (long long)fr[a[y] ^ k];
      if (k) fr[a[y]]--;
    }
    ans[qr[i].i] = s;
  }
  for (int i = 0; i < q; i++) printf("%lld\n", ans[i]);
  return 0;
}
