#include <bits/stdc++.h>
using namespace std;
long long t, n, m, dp1[300005], dp2[300005], fix[300005], xx, yy,
    mod = 998244353LL, may, mayb, col[300005], o, sz, ans;
vector<long long> v[300005], vv;
void go(long long x) {
  may = 0;
  mayb = 0;
  fix[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (col[v[x][i]] == 1) may = 1;
    if (col[v[x][i]] == 2) mayb = 1;
  }
  if (may && mayb) {
    o = 1;
    return;
  }
  if (may) {
    col[x] = 2;
  }
  if (mayb) col[x] = 1;
  if (!may && !mayb) col[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    if (!fix[v[x][i]]) go(v[x][i]);
  }
}
void dfs(long long x) {
  vv.push_back(x);
  fix[x] = 1;
  sz++;
  for (int i = 0; i < v[x].size(); i++) {
    if (!fix[v[x][i]]) dfs(v[x][i]);
  }
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      col[i] = 0;
      fix[i] = 0;
      dp1[i] = 0;
      dp2[i] = 0;
      v[i].clear();
    }
    for (int i = 1; i <= m; i++) {
      cin >> xx >> yy;
      v[xx].push_back(yy);
      v[yy].push_back(xx);
    }
    for (int i = 1; i <= n; i++) {
      if (!fix[i]) {
        o = 0;
        go(i);
        if (o) break;
      }
    }
    if (o) {
      cout << 0 << endl;
      continue;
    }
    ans = 1;
    for (int i = 1; i <= n; i++) fix[i] = 0;
    for (int i = 1; i <= n; i++) {
      if (!fix[i]) {
        sz = 0;
        long long g = 1, gg = 1;
        vv.clear();
        dfs(i);
        for (int j = 0; j < vv.size(); j++) {
          if (col[vv[j]] == 1) {
            g *= 2;
            g %= mod;
          }
          if (col[vv[j]] == 2) {
            gg *= 2;
            gg %= mod;
          }
        }
        ans *= g + gg;
        ans %= mod;
      }
    }
    cout << (ans % mod) << endl;
  }
  return 0;
}
