#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
  return x * f;
}
const int N = 2e3 + 5, mod = 1e9 + 7;
inline int inc(int x, int y) {
  x += y - mod;
  return x + (x >> 31 & mod);
}
inline int del(int x, int y) {
  x -= y;
  return x + (x >> 31 & mod);
}
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline void Inc(int &x, int y) { x = inc(x, y); }
int fa[N], siz[N], a[N];
int n, m, f[2][N << 2][2];
inline int get(int x) { return x == fa[x] ? x : fa[x] = get(fa[x]); }
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) fa[i] = i, siz[i] = 1;
  for (int i = 1; i <= m; i++) {
    int x = get(read()), y = get(read());
    if (x == 1 || y == 1 || x == y) continue;
    fa[y] = x, siz[x] += siz[y];
  }
  int t = 0;
  for (int i = 2; i <= n; i++)
    if (fa[i] == i) a[++t] = siz[i] + 1;
  n = t;
  int dt = 2 * m + 1;
  f[0][m + 1][0] = 1;
  int now = 0, last = 1;
  for (int i = 1; i <= n; i++) {
    now ^= 1, last ^= 1;
    for (int j = 1; j <= dt; j++) {
      f[now][j][0] = f[last][j][0];
      f[now][j][1] = f[last][j][1];
      if (j - a[i] >= 1) {
        Inc(f[now][j][0], f[last][j - a[i]][0]);
        Inc(f[now][j][1], f[last][j - a[i]][1]);
      }
      if (j + a[i] <= dt) {
        Inc(f[now][j][0], f[last][j + a[i]][0]);
        Inc(f[now][j][1], f[last][j + a[i]][1]);
      }
    }
    for (int j = 1; j <= dt; j++) Inc(f[last][j][0], f[last][j - 1][0]);
    for (int j = 1; j <= dt; j++) {
      int l = max(1, j - a[i] + 2), r = min(dt, j + a[i] - 2);
      Inc(f[now][j][1], del(f[last][r][0], f[last][l - 1][0]));
    }
  }
  int ans = 0;
  ans = inc(f[now][m + 1][1], f[now][m + 1][1]);
  memset(f, 0, sizeof(f));
  f[0][m + 1][0] = 1;
  now = 0, last = 1;
  for (int i = 1; i <= n; i++) {
    now ^= 1, last ^= 1;
    for (int j = 1; j <= dt; j++) {
      f[now][j][0] = f[now][j][1] = 0;
      if (j - a[i] >= 1) {
        Inc(f[now][j][0], f[last][j - a[i]][0]);
        Inc(f[now][j][1], f[last][j - a[i]][1]);
      }
      if (j + a[i] <= dt) {
        Inc(f[now][j][0], f[last][j + a[i]][0]);
        Inc(f[now][j][1], f[last][j + a[i]][1]);
      }
      if (j - a[i] + 1 >= 1) Inc(f[now][j][1], f[last][j - a[i] + 1][0]);
      if (j + a[i] - 1 <= dt) Inc(f[now][j][1], f[last][j + a[i] - 1][0]);
    }
  }
  Inc(ans, inc(inc(f[now][m + 1][1], f[now][m + 1][1]), f[now][m + 1][0]));
  printf("%d\n", ans);
  return 0;
}
