#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long PO(long long a, long long n) {
  long long val = 1;
  for (long long i = 0; i < n; i++) val *= a;
  return val;
}
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
long long vis[300001] = {0};
long long cnt = 0;
long long flag = 0;
long long cc = 0;
void init(long long n) {
  flag = 0;
  cnt = 0;
  for (long long i = 0; i <= n; i++) vis[i] = false;
}
void dfs(long long s, long long val, vector<long long> gr[]) {
  cc++;
  vis[s] = val;
  if (val == 1) {
    cnt++;
    val = 2;
  } else
    val = 1;
  for (long long i = 0; i < gr[s].size(); i++) {
    if (!vis[gr[s][i]]) {
      dfs(gr[s][i], val, gr);
    }
  }
}
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    ;
    long long m;
    cin >> m;
    ;
    init(n);
    vector<long long> gr[n + 1];
    vector<pair<long long, long long> > inpu;
    for (long long i = 0; i < m; i++) {
      long long x;
      cin >> x;
      ;
      long long y;
      cin >> y;
      ;
      inpu.push_back({x, y});
      gr[x].push_back(y);
      gr[y].push_back(x);
    }
    long long ans = 1;
    init(n);
    cc = 0;
    for (long long i = 1; i <= n; i++) {
      long long pre = cc;
      if (!vis[i]) {
        cnt = 0;
        dfs(i, 1, gr);
        long long size = cc - pre;
        ans *= (power(2, cnt, 998244353) + power(2, size - cnt, 998244353)) %
               998244353;
        ans %= 998244353;
      }
    }
    flag = 0;
    for (long long i = 0; i < m; i++) {
      if ((vis[inpu[i].first] + vis[inpu[i].second]) % 2 == 0) flag++;
    }
    if (flag)
      cout << 0 << "\n";
    else
      cout << ans << "\n";
  }
}
