#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 1;
int t, n, q, l, r, ans, sum;
int a[N], s1[N], s2[N];
char c[N];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &q);
    cin >> (c + 1);
    for (int i = 1; i <= n; i = -~i) {
      if (c[i] == '+')
        a[i] = 1;
      else
        a[i] = -1;
      s1[i] = s1[i - 1] + a[i] * (i % 2 ? 1 : -1);
      s2[i] = s2[i - 1] + a[i] * (i % 2 ? -1 : 1);
    }
    while (q--) {
      scanf("%d%d", &l, &r);
      if (l % 2)
        ans = s1[r] - s1[l - 1];
      else
        ans = s2[r] - s2[l - 1];
      sum = r - l + 1;
      if (!ans)
        printf("0\n");
      else if (sum % 2)
        printf("1\n");
      else
        printf("2\n");
    }
  }
  return 0;
}
