#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 3;
char s[N];
int a[N];
int main() {
  int t, n, q, l, r;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &q);
    scanf("%s", s + 1);
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      int cc = 1;
      if (s[i] == '-') {
        cc *= -1;
      }
      if (i % 2 == 0) cc *= -1;
      a[i] = a[i - 1] + cc;
    }
    for (int i = 1; i <= q; i++) {
      scanf("%d%d", &l, &r);
      int cc = a[r] - a[l - 1];
      if (cc == 0)
        puts("0");
      else if ((r - l) % 2 == 0) {
        puts("1");
      } else
        puts("2");
    }
  }
  return 0;
}
