#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<pair<long long int, long long int>> pre(n + 1);
    pre[0].first = 0, pre[0].second = 0;
    long long int add = 0, minus = 0, sum = 0;
    for (int i = 0; i < n; i++) {
      if ((i + 1) % 2 == 1) {
        if (s[i] == '+')
          add++;
        else
          minus++;
      } else if ((i + 1) % 2 == 0) {
        if (s[i] == '+')
          minus++;
        else
          add++;
      }
      pre[i + 1] = {add, minus};
    }
    while (q--) {
      long long int f1, f2;
      cin >> f1 >> f2;
      long long int preSum = (pre[f2].first - pre[f1 - 1].first);
      preSum -= (pre[f2].second - pre[f1 - 1].second);
      preSum = abs(preSum);
      if (preSum == 0)
        cout << 0;
      else if (preSum % 2 == 1)
        cout << 1;
      else if (preSum % 2 == 0)
        cout << 2;
      cout << endl;
    }
  }
  return 0;
}
