#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<pair<int, int>> v(n, {0, 0});
    for (int i = n - 1; i >= 0; i--) {
      v[i].first = v[i + 1].first;
      v[i].second = v[i + 1].second;
      if ((s[i] == '+' and i % 2 == 0) or (s[i] == '-' and i % 2 != 0)) {
        v[i].first++;
      } else {
        v[i].second++;
      }
    }
    while (q--) {
      int l, r;
      cin >> l >> r;
      l--;
      r--;
      if (v[l].first - v[r + 1].first == v[l].second - v[r + 1].second) {
        cout << "0\n";
      } else if ((v[l].first - v[r + 1].first + v[l].second - v[r + 1].second) %
                     2 !=
                 0) {
        cout << "1\n";
      } else {
        cout << "2\n";
      }
    }
  }
  return 0;
}
