#include <bits/stdc++.h>
using namespace std;
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;
template <typename T>
inline void read(T &x) {
  char ch, t = 0;
  x = 0;
  while (!isdigit(ch = (iS == iT
                            ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                               (iS == iT ? EOF : *iS++))
                            : *iS++)))
    t |= ch == '-';
  while (isdigit(ch))
    x = x * 10 + (ch ^ 48),
    ch = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                      (iS == iT ? EOF : *iS++))
                   : *iS++);
  x = t ? -x : x;
}
inline char read_alpha() {
  char c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                        (iS == iT ? EOF : *iS++))
                     : *iS++);
  while (!isalpha(c) && c != EOF)
    c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                     (iS == iT ? EOF : *iS++))
                  : *iS++);
  return c;
}
inline int read_int() {
  int x;
  return read(x), x;
}
inline long long read_ll() {
  long long x;
  return read(x), x;
}
template <typename T>
inline void chkmin(T &a, T b) {
  a = a < b ? a : b;
}
template <typename T>
inline void chkmax(T &a, T b) {
  a = a > b ? a : b;
}
const int MAXN = 100010;
const int mod = 1e9 + 7;
inline int Mod(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y, x -= x >= mod ? mod : 0; }
int id[MAXN];
int sgn[MAXN];
int deg[MAXN];
int vis[MAXN];
int tot;
int to[MAXN << 1];
int ne[MAXN << 1];
int rv[MAXN << 1];
int fi[MAXN];
int dg[MAXN];
inline void Link(int u, int v, int w) {
  tot++;
  to[tot] = v;
  rv[tot] = w;
  ne[tot] = fi[u];
  fi[u] = tot;
}
inline void AddEdge(int u, int v, int w) {
  Link(u, v, w), Link(v, u, w), ++dg[u], ++dg[v];
}
int rev[MAXN];
int sta[MAXN];
int top;
inline void dfs(int x) {
  sta[++top] = x, vis[x] = 1;
  for (int i = fi[x]; i; i = ne[i]) {
    int u = to[i];
    if (vis[u]) continue;
    rev[top] = rv[i];
    dfs(u);
  }
}
int res[2];
int main() {
  int m = read_int(), n = read_int(), c0 = 0, c1 = 0;
  for (int i = 1; i <= m; i++) {
    int k = read_int(), x, y;
    if (k == 2)
      x = read_int(), y = read_int();
    else
      x = read_int();
    deg[i] = k;
    if (k == 2) {
      if (x == y) {
        c0++, vis[i] = 1, id[abs(x)] = i;
        continue;
      }
      if (x == -y) {
        c1++, vis[i] = 1, id[abs(x)] = i;
        continue;
      }
    }
    if (id[abs(x)])
      AddEdge(i, id[abs(x)], (x < 0) ^ sgn[abs(x)]);
    else
      id[abs(x)] = i, sgn[abs(x)] = x < 0;
    if (k == 2) {
      if (id[abs(y)])
        AddEdge(i, id[abs(y)], (y < 0) ^ sgn[abs(y)]);
      else
        id[abs(y)] = i, sgn[abs(y)] = y < 0;
    }
  }
  res[0] = 1;
  while (c0--) res[0] = res[1] = Mod(res[0] + res[1]);
  while (c1--)
    res[0] = Mod(res[0] << 1), res[1] = Mod(res[1] << 1), swap(res[0], res[1]);
  int mul = 1;
  for (int i = 1; i <= n; i++)
    if (!id[i]) mul = Mod(mul << 1);
  for (int i = 1; i <= m; i++) {
    if (vis[i]) continue;
    if (!dg[i]) {
      vis[i] = 1;
      if (deg[i] == 1)
        res[0] = res[1] = Mod(res[0] + res[1]);
      else {
        int tr0 = (res[0] + 3LL * res[1]) % mod;
        int tr1 = (3LL * res[0] + res[1]) % mod;
        res[0] = tr0, res[1] = tr1;
      }
    }
    if (dg[i] == 1) {
      top = 0, dfs(i);
      int r0 = 1, r1 = 0, r2 = 0, r3 = 0;
      if (deg[sta[1]] == 2) r2 = 1;
      for (int j = 1; j < top; j++) {
        int tr0, tr1, tr2, tr3;
        if (rev[j]) {
          tr0 = Mod(r1 + r3), tr1 = Mod(r0 + r2);
          tr2 = Mod(r0 + r3), tr3 = Mod(r1 + r2);
        } else {
          tr0 = Mod(r0 + r3), tr1 = Mod(r1 + r2);
          tr2 = Mod(r1 + r3), tr3 = Mod(r0 + r2);
        }
        r0 = tr0, r1 = tr1, r2 = tr2, r3 = tr3;
      }
      if (deg[sta[top]] == 2) Add(r2, Mod(r0 + r2)), Add(r3, Mod(r3 + r1));
      Add(r0, r3), Add(r1, r2);
      int tr0 = (1LL * r0 * res[0] + 1LL * r1 * res[1]) % mod;
      int tr1 = (1LL * r1 * res[0] + 1LL * r0 * res[1]) % mod;
      res[0] = tr0, res[1] = tr1;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (vis[i]) continue;
    top = 0, dfs(i);
    int R0 = 0, R1 = 0, r0, r1, r2, r3, Rv = 0;
    for (int j = fi[sta[1]]; j; j = ne[j])
      if (to[j] == sta[top]) Rv = rv[j];
    r0 = 1, r1 = 0, r2 = 0, r3 = 0;
    for (int j = 1; j < top; j++) {
      int tr0, tr1, tr2, tr3;
      if (rev[j]) {
        tr0 = Mod(r1 + r3), tr1 = Mod(r0 + r2);
        tr2 = Mod(r0 + r3), tr3 = Mod(r1 + r2);
      } else {
        tr0 = Mod(r0 + r3), tr1 = Mod(r1 + r2);
        tr2 = Mod(r1 + r3), tr3 = Mod(r0 + r2);
      }
      r0 = tr0, r1 = tr1, r2 = tr2, r3 = tr3;
    }
    if (Rv)
      R0 = Mod(r1 + r3), R1 = Mod(r0 + r2);
    else
      R0 = Mod(r0 + r3), R1 = Mod(r1 + r2);
    cerr << R0 << ' ' << R1 << endl;
    r0 = 0, r1 = 0, r2 = 1, r3 = 0;
    for (int j = 1; j < top; j++) {
      int tr0, tr1, tr2, tr3;
      if (rev[j]) {
        tr0 = Mod(r1 + r3), tr1 = Mod(r0 + r2);
        tr2 = Mod(r0 + r3), tr3 = Mod(r1 + r2);
      } else {
        tr0 = Mod(r0 + r3), tr1 = Mod(r1 + r2);
        tr2 = Mod(r1 + r3), tr3 = Mod(r0 + r2);
      }
      r0 = tr0, r1 = tr1, r2 = tr2, r3 = tr3;
    }
    if (Rv)
      Add(R0, Mod(r0 + r3)), Add(R1, Mod(r1 + r2));
    else
      Add(R0, Mod(r1 + r3)), Add(R1, Mod(r0 + r2));
    int tr0 = (1LL * R0 * res[0] + 1LL * R1 * res[1]) % mod;
    int tr1 = (1LL * R1 * res[0] + 1LL * R0 * res[1]) % mod;
    res[0] = tr0, res[1] = tr1;
  }
  cout << 1LL * res[1] * mul % mod << endl;
  return 0;
}
