#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> inv_help(long long a, long long b) {
  pair<long long, long long> res;
  res.first = 1;
  res.second = 0;
  if (b == 0)
    return res;
  else {
    pair<long long, long long> res1 = inv_help(b, a % b);
    res.first = res1.second;
    res.second = res1.first - (a / b) * res1.second;
    return res;
  }
}
long long inv(long long a, long long b) {
  pair<long long, long long> res = inv_help(a, b);
  long long x = res.first;
  if (x > 0) x = x % b;
  if (x < 0) x = (b - (-x) % b) % b;
  return x;
}
int n;
int m;
vector<vector<int> > v;
vector<int> visit, value, visit_temp;
bool check_odd_help(int vertex, int val) {
  value[vertex] = val;
  visit[vertex] = 1;
  int sz = v[vertex].size();
  val++;
  val = val % 2;
  for (int i = 0; i < sz; i++) {
    if (visit[v[vertex][i]] == 1) {
      if (value[v[vertex][i]] != val) {
        return false;
      }
    } else {
      if (!check_odd_help(v[vertex][i], val)) return false;
    }
  }
  return true;
}
long long count_good_help(int vertex, int val) {
  visit[vertex] = 1;
  int sz = v[vertex].size();
  long long prod = 1;
  if (val == 1) prod = 2;
  val++;
  val = val % 2;
  for (int i = 0; i < sz; i++) {
    if (visit[v[vertex][i]] != 1) {
      prod = (prod * count_good_help(v[vertex][i], val)) % 998244353;
    }
  }
  return prod;
}
long long count_good_help1(int vertex, int val) {
  visit_temp[vertex] = 1;
  int sz = v[vertex].size();
  long long prod = 1;
  if (val == 1) prod = 2;
  val++;
  val = val % 2;
  for (int i = 0; i < sz; i++) {
    if (visit_temp[v[vertex][i]] != 1) {
      prod = (prod * count_good_help1(v[vertex][i], val)) % 998244353;
    }
  }
  return prod;
}
bool check_odd() {
  for (int i = 0; i < n; i++) {
    if (visit[i] == -1) {
      if (!check_odd_help(i, 0)) return false;
    }
  }
  return true;
}
long long count_good() {
  long long prod = 1;
  for (int i = 0; i < n; i++) {
    if (visit[i] == -1) {
      prod = (prod * ((count_good_help1(i, 0) + count_good_help(i, 1))) %
              998244353) %
             998244353;
    }
  }
  return prod;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cin >> n >> m;
    vector<vector<int> > v1(n, vector<int>(0, 0));
    vector<int> visit1(n, -1);
    v = v1;
    visit = visit1;
    value = visit1;
    int a, b;
    for (int i = 0; i < m; i++) {
      cin >> a >> b;
      a--;
      b--;
      v[a].push_back(b);
      v[b].push_back(a);
    }
    if (!check_odd()) {
      cout << 0 << "\n";
    } else {
      visit = visit1;
      visit_temp = visit1;
      int sum = count_good();
      cout << sum << "\n";
    }
  }
}
