#include <bits/stdc++.h>
using namespace std;
vector<long long int> vect[300006];
long long int vis[300006], q[300006], p[300006], a, b, f;
void dfs(int i, int c) {
  vis[i] = 1;
  q[i] = c;
  if (c == 0)
    a++;
  else
    b++;
  for (int j = 0; j < vect[i].size(); j++) {
    if (vis[vect[i][j]] == 1 && q[vect[i][j]] == c) {
      f = -1;
      return;
    }
  }
  for (int j = 0; j < vect[i].size(); j++) {
    if (vis[vect[i][j]] == 1) continue;
    dfs(vect[i][j], c ^ 1);
    if (f == -1) return;
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long int i, t, n, m, u, v, x, ans;
  p[0] = 1;
  for (i = 1; i < 300005; i++) {
    p[i] = p[i - 1] * 2;
    p[i] %= 998244353;
  }
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (i = 0; i < m; i++) {
      cin >> u >> v;
      vect[u].push_back(v);
      vect[v].push_back(u);
    }
    ans = 1;
    for (i = 1; i <= n; i++) {
      if (vis[i] == 1) continue;
      a = b = f = 0;
      dfs(i, 0);
      if (f == -1)
        x = 0;
      else {
        x = p[a] + p[b];
        x %= 998244353;
      }
      ans *= x;
      ans %= 998244353;
    }
    cout << ans << endl;
    for (i = 1; i <= n; i++) {
      vis[i] = q[i] = 0;
      vect[i].clear();
    }
  }
  return 0;
}
