#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 3 * 1e5 + 5;
vector<int> graph[N];
int color[N];
int part[2];
int pow2[N];
bool flag = true;
void dfs(int node, int c) {
  color[node] = c;
  part[c] += 1;
  for (int child : graph[node]) {
    if (color[child] == -1) dfs(child, 1 - c);
    if (color[child] == color[node]) {
      flag = false;
      break;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  pow2[0] = 1;
  for (int i = 1; i < N; ++i) {
    pow2[i] = (1ll * pow2[i - 1] * 2) % MOD;
  }
  int tc;
  cin >> tc;
  for (int t = 0; t < tc; ++t) {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
      graph[i].clear();
      color[i] = -1;
    }
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      graph[a].push_back(b);
      graph[b].push_back(a);
    }
    int res = 0;
    int ans = 1;
    for (int i = 0; i < n; ++i) {
      if (color[i] == -1) {
        part[0] = 0;
        part[1] = 0;
        flag = true;
        dfs(i, 0);
        if (!flag) {
          ans = 0;
          break;
        }
        res = (1ll * pow2[part[0]] + 1ll * pow2[part[1]]) % MOD;
        ans = (1ll * ans * res) % MOD;
      }
    }
    cout << ans << endl;
  }
}
