#include <bits/stdc++.h>
using namespace std;
const int N = 300100;
int a[N], sum[N];
char s[N];
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n, q;
    cin >> n >> q >> s + 1;
    for (int i = 1; i <= n; i++) {
      if (s[i] == '+')
        a[i] = 1;
      else
        a[i] = -1;
      if (i % 2 == 0) a[i] = -1 * a[i];
    }
    for (int i = 1; i <= n; i++) {
      sum[i] = sum[i - 1] + a[i];
    }
    while (q--) {
      int l, r;
      cin >> l >> r;
      int res = sum[r] - sum[l - 1];
      if (res == 0)
        cout << 0 << endl;
      else if (res % 2 == 0)
        cout << 2 << endl;
      else
        cout << 1 << endl;
    }
  }
}
