#include <bits/stdc++.h>
using namespace std;
const int RLEN = 1 << 20 | 1;
inline char gc() {
  static char ibuf[RLEN], *ib, *ob;
  (ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin));
  return (ib == ob) ? EOF : *ib++;
}
inline int read() {
  char ch = gc();
  int res = 0;
  bool f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) res = (res + (res << 2) << 1) + (ch ^ 48), ch = gc();
  return f ? res : -res;
}
inline long long readll() {
  char ch = gc();
  long long res = 0;
  bool f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) res = (res + (res << 2) << 1) + (ch ^ 48), ch = gc();
  return f ? res : -res;
}
inline char readchar() {
  char ch = gc();
  while (isspace(ch)) ch = gc();
  return ch;
}
inline int readstring(char *s) {
  int top = 0;
  char ch = gc();
  while (isspace(ch)) ch = gc();
  while (!isspace(ch) && ch != EOF) s[++top] = ch, ch = gc();
  s[top + 1] = '\0';
  return top;
}
template <typename tp>
inline void chemx(tp &a, tp b) {
  a = max(a, b);
}
template <typename tp>
inline void chemn(tp &a, tp b) {
  a = min(a, b);
}
const int mod = 1e9 + 7;
inline int add(int a, int b) {
  return (a + b) >= mod ? (a + b - mod) : (a + b);
}
inline int dec(int a, int b) { return (a < b) ? (a - b + mod) : (a - b); }
inline int mul(int a, int b) {
  static long long r;
  r = (long long)a * b;
  return (r >= mod) ? (r % mod) : r;
}
inline void Add(int &a, int b) { a = (a + b) >= mod ? (a + b - mod) : (a + b); }
inline void Dec(int &a, int b) { a = (a < b) ? (a - b + mod) : (a - b); }
inline void Mul(int &a, int b) {
  static long long r;
  r = (long long)a * b;
  a = (r >= mod) ? (r % mod) : r;
}
inline int ksm(int a, int b, int res = 1) {
  for (; b; b >>= 1, Mul(a, a)) (b & 1) && (Mul(res, a), 1);
  return res;
}
inline int Inv(int x) { return ksm(x, mod - 2); }
inline int fix(long long x) {
  x %= mod;
  return (x < 0) ? x + mod : x;
}
const int N = 100005;
int vis[N], vt[N];
int n, m, id[N][2], bel[N][2], deg[N];
int ans[2], tmp[2], f[N][2], g[N][2][2], is_end[N];
int adj[N << 1], nxt[N << 2], to[N << 2], vl[N << 2], ecnt = 1;
inline void addedge(int u, int v, int w) {
  nxt[++ecnt] = adj[u], adj[u] = ecnt, to[ecnt] = v, vl[ecnt] = w;
}
int tot, trs[N];
bool fg;
void collect(int u, int fa) {
  vt[u] = 1;
  fg = (deg[u] == 1);
  for (int e = adj[u], v; e; e = nxt[e])
    if ((e ^ 1) != fa) {
      v = to[e];
      trs[++tot] = vl[e], collect(v, e);
    }
}
void collect_cir(int u, int fa, int rt) {
  vt[u] = 1;
  for (int e = adj[u], v; e && !fg; e = nxt[e])
    if ((e ^ 1) != fa) {
      v = to[e];
      trs[++tot] = vl[e];
      if (v == rt) {
        fg = 1;
        return;
      }
      collect_cir(v, e, rt);
    }
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) {
    int cnt = read();
    deg[i] = cnt;
    if (cnt == 1) {
      int x = read(), t = abs(x);
      id[t][vis[t]] = x > 0, bel[t][vis[t]] = i;
      vis[t]++, is_end[i] = 1;
      continue;
    }
    int x = read(), u = abs(x), y = read(), v = abs(y);
    id[u][vis[u]] = x > 0, bel[u][vis[u]] = i;
    vis[u]++;
    id[v][vis[v]] = y > 0, bel[v][vis[v]] = i;
    vis[v]++;
  }
  ans[0] = 1;
  for (int i = 1; i <= m; i++)
    if (vis[i]) {
      if (vis[i] == 1) {
        is_end[bel[i][0]] = 1;
      } else {
        int u = bel[i][0], v = bel[i][1], t = id[i][0] ^ id[i][1];
        if (u == v) {
          if (!t)
            ans[0] = ans[1] = add(ans[0], ans[1]);
          else
            Mul(ans[0], 2), Mul(ans[1], 2), swap(ans[0], ans[1]);
          vt[u] = 1;
          continue;
        }
        addedge(u, v, t), addedge(v, u, t);
      }
    } else
      Mul(ans[0], 2), Mul(ans[1], 2);
  for (int i = 1; i <= n; i++)
    if (is_end[i] == 1 && !vt[i]) {
      if (adj[i] == 0) {
        vt[i] = 1;
        if (deg[i] == 1)
          ans[0] = ans[1] = add(ans[0], ans[1]);
        else
          tmp[0] = add(ans[0], mul(3, ans[1])),
          tmp[1] = add(ans[1], mul(3, ans[0])), ans[0] = tmp[0],
          ans[1] = tmp[1], tmp[0] = tmp[1] = 0;
        continue;
      }
      tot = 0;
      collect(i, 0);
      if (deg[i] == 1) {
        for (int j = 0; j < 2; j++) g[0][j][j]++;
      } else {
        for (int j = 0; j < 2; j++)
          for (int k = 0; k < 2; k++) g[0][j | k][k]++;
      }
      for (int j = 1; j < tot + (!fg); j++) {
        for (int t = 0; t < 2; t++)
          for (int k = 0; k < 2; k++)
            for (int l = 0; l < 2; l++)
              Add(g[j][k ^ ((l ^ trs[j]) | t)][t], g[j - 1][k][l]);
      }
      if (fg) {
        for (int k = 0; k < 2; k++)
          for (int l = 0; l < 2; l++)
            Add(g[tot][k ^ (l ^ trs[tot])][0], g[tot - 1][k][l]);
      }
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          for (int l = 0; l < 2; l++)
            Add(tmp[j ^ k], mul(ans[j], g[tot][k][l]));
      ans[0] = tmp[0], ans[1] = tmp[1], tmp[0] = tmp[1] = 0;
      for (int j = 0; j <= tot; j++) memset(g[j], 0, sizeof(g[j]));
    }
  for (int i = 1; i <= n; i++)
    if (!vt[i]) {
      tot = fg = 0, collect_cir(i, 0, i);
      g[0][0][0] = 1;
      for (int j = 1; j < tot; j++) {
        for (int k = 0; k < 2; k++)
          for (int l = 0; l < 2; l++)
            for (int t = 0; t < 2; t++)
              Add(g[j][k ^ ((l ^ trs[j]) | t)][t], g[j - 1][k][l]);
      }
      for (int k = 0; k < 2; k++)
        for (int l = 0; l < 2; l++)
          Add(g[tot][k ^ ((l ^ trs[tot]) | 0)][0], g[tot - 1][k][l]);
      for (int j = 0; j < tot; j++) memset(g[j], 0, sizeof(g[j]));
      g[0][0][1] = 1;
      for (int j = 1; j < tot; j++) {
        for (int k = 0; k < 2; k++)
          for (int l = 0; l < 2; l++)
            for (int t = 0; t < 2; t++)
              Add(g[j][k ^ ((l ^ trs[j]) | t)][t], g[j - 1][k][l]);
      }
      for (int k = 0; k < 2; k++)
        for (int l = 0; l < 2; l++)
          Add(g[tot][k ^ ((l ^ trs[tot]) | 1)][1], g[tot - 1][k][l]);
      for (int j = 0; j < tot; j++) memset(g[j], 0, sizeof(g[j]));
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          for (int l = 0; l < 2; l++)
            Add(tmp[j ^ k], mul(ans[j], g[tot][k][l]));
      ans[0] = tmp[0], ans[1] = tmp[1], tmp[0] = tmp[1] = 0;
      memset(g[tot], 0, sizeof(g[tot]));
    }
  cout << ans[1] << '\n';
  return 0;
}
