#include <bits/stdc++.h>
#pragma optimize(3, "Ofast", "inline")
using namespace std;
const int _ = 5;
const int maxn = 3e5;
int n, q;
int f[maxn + _][2][2];
char s[maxn + _];
int main() {
  int T = 1;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &q);
    scanf("%s", s + 1);
    memset(f[0], 0, sizeof(f[0]));
    for (int i = 1; i <= n; ++i) {
      for (int i1 = 0; i1 < 2; ++i1)
        for (int i2 = 0; i2 < 2; ++i2) f[i][i1][i2] = f[i - 1][i1][i2];
      f[i][i % 2][s[i] == '+']++;
    }
    while (q--) {
      int l, r;
      scanf("%d%d", &l, &r);
      int cnt[2][2];
      for (int i = 0; i < 2; ++i)
        for (int j = 0; j < 2; ++j) cnt[i][j] = f[r][i][j] - f[l - 1][i][j];
      int dif = cnt[0][0] - cnt[0][1] - cnt[1][0] + cnt[1][1];
      if (dif == 0)
        puts("0");
      else if (dif & 1)
        puts("1");
      else
        puts("2");
    }
  }
  return 0;
}
