#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
namespace ywy {
inline int get() {
  int n = 0;
  char c;
  while ((c = getchar()) || 23333) {
    if (c >= '0' && c <= '9') break;
    if (c == '-') goto s;
  }
  n = c - '0';
  while ((c = getchar()) || 23333) {
    if (c >= '0' && c <= '9')
      n = n * 10 + c - '0';
    else
      return n;
  }
s:
  while ((c = getchar()) || 23333) {
    if (c >= '0' && c <= '9')
      n = n * 10 - c + '0';
    else
      return n;
  }
}
typedef struct _n {
  int cnt, dl, dr;
  friend _n operator+(const _n &a, const _n &b) {
    if (a.cnt == 0) return b;
    if (b.cnt == 0) return a;
    if (a.dr == b.dl) {
      if (a.cnt == b.cnt) {
        _n c;
        c.cnt = c.dl = c.dr = 0;
        return c;
      }
      if (a.cnt > b.cnt) {
        _n c = a;
        c.cnt -= b.cnt;
        c.dr ^= (b.cnt & 1);
        return c;
      }
      _n c = b;
      c.cnt -= a.cnt;
      c.dl ^= (a.cnt & 1);
      return c;
    }
    _n c;
    c.cnt = a.cnt + b.cnt;
    c.dl = a.dl;
    c.dr = b.dr;
    return c;
  }
} node;
node data[300010 * 4], tmpl[300010 * 4], tmpr[300010 * 4];
char str[300010];
void build(int l, int r, int tree) {
  if (l == r) {
    data[tree].cnt = 1;
    data[tree].dl = data[tree].dr = (str[l] == '+');
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, (tree << 1));
  build(mid + 1, r, ((tree << 1) | 1));
  data[tree] = data[(tree << 1)] + data[((tree << 1) | 1)];
}
node query(int rl, int rr, int l, int r, int tree) {
  if (rl == l && rr == r) return data[tree];
  int mid = (l + r) >> 1;
  if (rl > mid) return query(rl, rr, mid + 1, r, ((tree << 1) | 1));
  if (rr <= mid) return query(rl, rr, l, mid, (tree << 1));
  tmpl[tree] = query(rl, mid, l, mid, (tree << 1));
  tmpr[tree] = query(mid + 1, rr, mid + 1, r, ((tree << 1) | 1));
  return tmpl[tree] + tmpr[tree];
}
int kth(int rl, int rr, int l, int r, int tree, int k) {
  if (l == r) return l;
  int mid = (l + r) >> 1;
  if (rl > mid) return kth(rl, rr, mid + 1, r, ((tree << 1) | 1), k);
  if (rr <= mid) return kth(rl, rr, l, mid, (tree << 1), k);
  if (rl == l && rr == r)
    tmpl[tree] = data[(tree << 1)], tmpr[tree] = data[((tree << 1) | 1)];
  if (tmpl[tree].cnt == 0)
    return kth(mid + 1, rr, mid + 1, r, ((tree << 1) | 1), k);
  if (tmpr[tree].cnt == 0) return kth(rl, mid, l, mid, (tree << 1), k);
  if (tmpl[tree].dr != tmpr[tree].dl) {
    if (k <= tmpl[tree].cnt) return kth(rl, mid, l, mid, (tree << 1), k);
    return kth(mid + 1, rr, mid + 1, r, ((tree << 1) | 1), k - tmpl[tree].cnt);
  }
  if (tmpl[tree].cnt > tmpr[tree].cnt)
    return kth(rl, mid, l, mid, (tree << 1), k);
  return kth(mid + 1, rr, mid + 1, r, ((tree << 1) | 1), k + tmpl[tree].cnt);
}
void ywymain() {
  int T = get();
  while (T--) {
    int n = get(), m = get();
    scanf("%s", str + 1);
    build(1, n, 1);
    for (int i = 1; i <= m; i++) {
      int l = get(), r = get();
      node ans = query(l, r, 1, n, 1);
      if (ans.cnt == 0)
        printf("0\n");
      else {
        if (ans.cnt & 1)
          printf("1\n");
        else
          printf("2\n");
      }
    }
  }
}
}  // namespace ywy
int main() {
  ywy::ywymain();
  return 0;
}
