#include <bits/stdc++.h>
using namespace std;
vector<long long int> v, v1, v2, v3, v4;
vector<pair<long long int, long long int> > vec, vec1;
vector<int> adj[300005];
map<long long int, long long int> Mp;
set<long long int> st, st1, st2;
queue<long long int> Q;
stack<long long int> Stk;
multiset<long long int> S;
int t, T, n, m, k, a, b, val, x, y;
void pre() {}
void Reset() {
  for (int i = 1; i <= n; i++) adj[i].clear();
  x = 0, y = 0;
}
void Input() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
}
bool bipertite(int *visited, int s) {
  visited[s] = 1;
  x++;
  queue<int> Q;
  Q.push(s);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (auto v : adj[u]) {
      if (!visited[v]) {
        if (visited[u] == 1) {
          y++;
          visited[v] = 2;
        } else {
          x++;
          visited[v] = 1;
        }
        Q.push(v);
      }
      if (visited[u] == visited[v]) return true;
    }
  }
  return false;
}
long long int Power[300005];
void power() {
  Power[0] = 1;
  for (int i = 1; i < 300002; i++) {
    Power[i] = (Power[i - 1] * 2LL) % 998244353;
  }
}
void Calculation() {
  int visited[n + 2];
  memset(visited, 0, sizeof visited);
  long long int ans = 1;
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      if (bipertite(visited, i)) {
        cout << 0 << endl;
        return;
      } else {
        ans = (ans % 998244353 * (Power[x] + Power[y]) % 998244353) % 998244353;
        x = 0, y = 0;
      }
    }
  }
  cout << ans << endl;
}
void solve() {
  Reset();
  Input();
  Calculation();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  power();
  cin >> t;
  while (t--) {
    T++;
    solve();
  }
  return 0;
}
