#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
bool f;
int col[N];
long long p1 = 0, p2 = 0;
const long long mod = 998244353;
vector<int> E[N];
void dfs(int u) {
  if (col[u] == 1)
    p1++;
  else
    p2++;
  for (int i = 0; i < E[u].size(); i++) {
    int v = E[u][i];
    if (!col[v]) {
      if (col[u] == 1)
        col[v] = 2;
      else if (col[u] == 2)
        col[v] = 1;
      dfs(v);
    } else if (col[u] == col[v])
      f = 0;
  }
}
long long fast_mod(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    b >>= 1;
    a = (a * a) % mod;
  }
  return res;
}
int main() {
  int t, n, m;
  cin >> t;
  while (t--) {
    f = 1;
    long long ans = 1;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
      int u, v;
      cin >> u >> v;
      E[u].push_back(v);
      E[v].push_back(u);
    }
    for (int i = 1; i <= n; i++) {
      if (!col[i]) {
        col[i] = 1;
        p1 = 0;
        p2 = 0;
        dfs(i);
        ans = ans * ((fast_mod(2, p1) + fast_mod(2, p2)) % mod) % mod;
      }
    }
    if (!f)
      cout << 0 << endl;
    else
      cout << ans << endl;
    for (int i = 1; i <= n; i++) E[i].clear(), col[i] = 0;
  }
  return 0;
}
