#include <bits/stdc++.h>
using namespace std;
long long int p = 998244353;
long long int DFS(long long int s, vector<vector<long long int>> &adj,
                  vector<bool> &vis, vector<bool> &col, long long int &ecnt,
                  long long int &c) {
  for (long long int j = 0; j < adj[s].size(); j++) {
    if (!vis[adj[s][j]]) {
      c++;
      vis[adj[s][j]] = 1;
      col[adj[s][j]] = (!col[s]);
      if (col[adj[s][j]] == 0) {
        ecnt++;
      }
      long long int x = DFS(adj[s][j], adj, vis, col, ecnt, c);
      if (x == -1) {
        ecnt = -1;
        return -1;
      }
    } else {
      if (col[adj[s][j]] == col[s]) {
        ecnt = -1;
        return -1;
      }
    }
  }
  return ecnt;
}
long long int solve(long long int n, long long int m,
                    vector<long long int> &power) {
  vector<vector<long long int>> adj(n + 1);
  for (long long int j = 0; j < m; j++) {
    long long int v1, v2;
    cin >> v1 >> v2;
    adj[v1].push_back(v2);
    adj[v2].push_back(v1);
  }
  vector<bool> vis(n + 1);
  vector<bool> col(n + 1);
  long long int ans = 1;
  for (long long int j = 1; j <= n; j++) {
    if (!vis[j]) {
      long long int c = 1;
      col[j] = 0;
      long long int ecnt = 1;
      vis[j] = 1;
      DFS(j, adj, vis, col, ecnt, c);
      if (!(ecnt == -1)) {
        ans *= power[ecnt] + power[c - ecnt];
        ans %= p;
      } else {
        return 0;
      }
    }
  }
  return ans % p;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  vector<long long int> power(1000000, 1);
  for (long long int j = 1; j < 1000000; j++) {
    power[j] = (power[j - 1] * 2) % p;
  }
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    long long int ans = solve(n, m, power);
    cout << ans;
    cout << "\n";
  }
  return 0;
}
