#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> where[100005];
vector<int> g[100005];
bool done[100005] = {};
int d[2][2], nd[2][2];
int e[100005];
vector<pair<int, int> > res;
const int MOD = 1e9 + 7;
inline void modAdd(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)(n); ++i) {
    int cnt;
    scanf("%d", &cnt);
    for (int j = 0; j < (int)(cnt); ++j) {
      int x;
      scanf("%d", &x);
      g[i].push_back(x);
      where[abs(x)].push_back(i);
    }
  }
  for (int ii = 0; ii < (int)(2 * n); ++ii)
    if (!done[ii % n]) {
      int i = ii % n;
      if (ii < n) {
        int trs = 0;
        for (int x : g[i])
          if (where[abs(x)].size() == 2) {
            ++trs;
          }
        if (trs == 2) continue;
      }
      vector<int> all, tr;
      bool cyc = false;
      int cycVar = -1;
      int firstVar = -1;
      for (int j = i;;) {
        done[j] = true;
        all.push_back(j);
        int nx = -1;
        int curTr = -1;
        bool locCyc = false;
        for (int x : g[j]) {
          x = abs(x);
          for (int y : where[x])
            if (!done[y] && nx == -1) {
              nx = y;
              if (j == i) firstVar = x;
              curTr = x;
            } else if (y == i && x != firstVar) {
              locCyc = true;
              cycVar = x;
            }
        }
        if (nx == -1) {
          cyc = locCyc;
          break;
        }
        int dif = 0;
        for (int x : g[j])
          if (abs(x) == curTr && x > 0) dif ^= 1;
        for (int x : g[nx])
          if (abs(x) == curTr && x > 0) dif ^= 1;
        tr.push_back(dif);
        j = nx;
      }
      for (int x : all) done[x] = true;
      if ((int)all.size() == 1) {
        if ((int)g[i].size() == 1 || g[i][0] == g[i][1]) {
          res.push_back(make_pair(1, 1));
        } else if (abs(g[i][0]) == abs(g[i][1])) {
          res.push_back(make_pair(0, 2));
        } else {
          res.push_back(make_pair(1, 3));
        }
      } else {
        int sz = (int)all.size();
        int zero = 0, one = 0;
        for (int c = 0; c < 2; ++c)
          for (int ce = 0; ce < 2; ++ce) {
            if (cyc && ce == 1) continue;
            if (!cyc) {
              if (c == 1 && (int)g[all[0]].size() == 1) continue;
              if (ce == 1 && (int)g[all.back()].size() == 1) continue;
            }
            for (int j = 0; j <= sz; ++j) e[j] = 0;
            if (cyc) {
              for (int x : g[all[0]])
                if (abs(x) == cycVar) {
                  e[0] = c ^ (x > 0);
                }
              for (int x : g[all.back()])
                if (abs(x) == cycVar) {
                  e[sz - 1] = c ^ (x > 0);
                }
            } else {
              e[0] = c;
              e[sz - 1] = ce;
            }
            d[0][0] = 1;
            d[0][1] = d[1][0] = d[1][1] = 0;
            for (int j = 0; j < sz - 1; ++j) {
              nd[0][0] = nd[0][1] = nd[1][0] = nd[1][1] = 0;
              for (int a = 0; a < (int)(2); ++a)
                for (int b = 0; b < (int)(2); ++b) {
                  int aa = a | e[j];
                  for (int c = 0; c < (int)(2); ++c) {
                    int na = c ^ tr[j];
                    int nb = b ^ (aa | c);
                    modAdd(nd[na][nb], d[a][b]);
                  }
                }
              memcpy(d, nd, sizeof d);
            }
            for (int a = 0; a < (int)(2); ++a)
              for (int b = 0; b < (int)(2); ++b) {
                if ((e[sz - 1] | a) ^ b)
                  modAdd(one, d[a][b]);
                else
                  modAdd(zero, d[a][b]);
              }
          }
        res.push_back(make_pair(zero, one));
      }
    }
  int z = 1, o = 0, nz, no;
  for (pair<int, int> x : res) {
    nz = ((long long)z * x.first + (long long)o * x.second) % MOD;
    no = ((long long)o * x.first + (long long)z * x.second) % MOD;
    z = nz;
    o = no;
  }
  for (int i = 1; i <= m; ++i)
    if (where[i].empty()) {
      o = 2ll * o % MOD;
    }
  printf("%d\n", o);
  return 0;
}
