#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int _;
  for (cin >> _; _--;) {
    int n, q;
    cin >> n >> q;
    string a;
    cin >> a;
    vector<int> p(n);
    p[0] = (a[0] == '+' ? 1 : -1);
    for (int i = 1; i < n; i++) {
      if (i % 2)
        p[i] = p[i - 1] - (a[i] == '+' ? 1 : -1);
      else
        p[i] = p[i - 1] + (a[i] == '+' ? 1 : -1);
    }
    vector<int> s(n);
    s[n - 1] = (a[n - 1] == '+' ? 1 : -1);
    for (int i = n - 2; i >= 0; i--) {
      if ((n - 1 - i) % 2)
        s[i] = s[i + 1] - (a[i] == '+' ? 1 : -1);
      else
        s[i] = s[i + 1] + (a[i] == '+' ? 1 : -1);
    }
    while (q--) {
      int l, r;
      cin >> l >> r;
      l--, r--;
      if (l == 0) {
        if (p[r] == 0) {
          cout << "0\n";
          continue;
        }
      } else {
        if (p[r] == p[l - 1]) {
          cout << "0\n";
          continue;
        }
      }
      int s1 = 0, s2 = 0;
      if (l == 0)
        s1 = p[r];
      else {
        if (l % 2 == 0) {
          s1 = p[r] - p[l - 1];
        } else {
          s1 = p[l - 1] - p[r];
        }
      }
      if (r == n - 1)
        s2 = s[l];
      else {
        if ((n - 1 - r) % 2 == 0) {
          s2 = s[l] - s[r + 1];
        } else {
          s2 = s[r + 1] - s[l];
        }
      }
      if (s1 == s2) {
        cout << "1\n";
      } else {
        cout << "2\n";
      }
    }
  }
  return 0;
}
