#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
long long ext_gcd(long long A, long long B, long long* X, long long* Y) {
  long long x2, y2, x1, y1, x, y, r2, r1, q, r;
  x2 = 1;
  y2 = 0;
  x1 = 0;
  y1 = 1;
  for (r2 = A, r1 = B; r1 != 0;
       r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y) {
    q = r2 / r1;
    r = r2 % r1;
    x = x2 - (q * x1);
    y = y2 - (q * y1);
  }
  *X = x2;
  *Y = y2;
  return r2;
}
inline long long modInv(long long a, long long m) {
  long long x, y;
  ext_gcd(a, m, &x, &y);
  x %= m;
  if (x < 0) x += m;
  return x;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1 % m, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
const long long inf = 2147383647;
const long long mod = 998244353;
const double pi = 2 * acos(0.0);
const double eps = 1e-11;
int color[300010];
vector<int> G[300010];
vector<pair<int, int> > myvec;
int color1cnt, color2cnt;
bool Bicoloring(int source) {
  queue<int> Q;
  Q.push(source);
  color1cnt = 0;
  color2cnt = 0;
  color[source] = 1;
  color1cnt++;
  while (Q.size() != 0) {
    int u = Q.front();
    Q.pop();
    for (int v = 0; v < G[u].size(); v++) {
      int curr = G[u][v];
      if (color[curr] == 0) {
        if (color[u] == 1) {
          color[curr] = 2;
          color2cnt++;
        } else {
          color[curr] = 1;
          color1cnt++;
        }
        Q.push(curr);
      }
      if (color[u] == color[curr]) return false;
    }
  }
  myvec.push_back(pair<int, int>(color1cnt, color2cnt));
  return true;
}
int bigmodAra[300010];
void pre() {
  bigmodAra[0] = 1;
  for (int i = 1; i <= 300005; i++) {
    bigmodAra[i] = (bigmodAra[i - 1] * 2) % mod;
  }
}
int main() {
  pre();
  int tc;
  scanf("%d", &tc);
  for (int i = 0; i < tc; i++) {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int j = 0; j <= n; j++) {
      G[j].clear();
      color[j] = 0;
    }
    myvec.clear();
    for (int j = 0; j < m; j++) {
      int a, b;
      scanf("%d %d", &a, &b);
      G[a].push_back(b);
      G[b].push_back(a);
    }
    int flag = 1;
    for (int j = 1; j <= n; j++) {
      if (flag) {
        if (color[j] == 0) {
          bool temp = Bicoloring(j);
          if (temp == false) {
            flag = 0;
            break;
          }
        }
      }
    }
    if (!flag) {
      printf("0\n");
    } else {
      long long ret = 1;
      for (int j = 0; j < myvec.size(); j++) {
        long long cnt1 = myvec[j].first;
        long long cnt2 = myvec[j].second;
        long long temp1 = bigmodAra[cnt1];
        long long temp2 = bigmodAra[cnt2];
        long long temp = (temp1 + temp2) % mod;
        ret = (ret * temp) % mod;
      }
      printf("%lld\n", ret);
    }
  }
  return 0;
}
