#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n, m;
string s;
int sum[N];
void solve() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  s = ' ' + s;
  for (int i = 1; i <= n; i++) {
    int r = 1;
    if (i % 2 == 0) r = -1;
    if (s[i] == '-') r = -r;
    sum[i] = sum[i - 1] + r;
  }
  while (q--) {
    int l, r;
    cin >> l >> r;
    if ((r - l + 1) & 1)
      cout << 1 << '\n';
    else {
      if (sum[r] - sum[l - 1] == 0)
        cout << 0 << '\n';
      else
        cout << 2 << '\n';
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cout.precision(2), cout.setf(ios::fixed);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
