#include <bits/stdc++.h>
using namespace std;
int gcd(int f, int s) {
  if (s == 0)
    return f;
  else
    return gcd(s, f % s);
}
int const N = 1002006;
long long const M = 998244353;
long double const ep = .000000000000000001;
vector<int> G[N];
long long pw[N];
int od = 0, ev = 0;
int vis[N];
bool wtf = 1;
void dfs(int node, int col) {
  if (col % 2 == 0)
    ev++;
  else
    od++;
  vis[node] = col;
  for (int i = 0; i < G[node].size(); i++) {
    int el = G[node][i];
    if (vis[el] == -1)
      dfs(el, col ^ 1);
    else if (col == vis[el])
      wtf = 0;
  }
}
int main() {
  pw[0] = 1;
  for (int i = 1; i < N; i++) pw[i] = (pw[i - 1] * 2) % M;
  int t;
  cin >> t;
  while (t--) {
    int n, e;
    scanf("%d%d", &n, &e);
    for (int i = 1; i <= n; i++) {
      G[i].clear();
      vis[i] = -1;
    }
    for (int i = 0; i < e; i++) {
      int temp, temp1;
      scanf("%d%d", &temp, &temp1);
      G[temp].push_back(temp1);
      G[temp1].push_back(temp);
    }
    wtf = 1;
    long long ans = 1;
    for (int i = 1; i <= n; i++) {
      if (vis[i] == -1) {
        od = 0, ev = 0;
        dfs(i, 0);
        long long tot = pw[od] + pw[ev];
        tot %= M;
        ans = (ans * tot) % M;
      }
    }
    ans *= wtf;
    printf("%lld\n", ans);
  }
  return 0;
}
