#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void checkmin(T &a, T b) {
  if (b < a) {
    a = b;
  }
}
template <typename T>
inline void checkmax(T &a, T b) {
  if (b > a) {
    a = b;
  }
}
const int maxn = (int)1e5 + 10;
const int mod = (int)1e9 + 7;
vector<int> adj[maxn << 2];
vector<int> cl[maxn];
bool mark[maxn << 1];
int dp[maxn][2][2];
int dp2[maxn][2];
int n, m;
void dfs(int u, vector<int> &path) {
  mark[u] = true;
  path.emplace_back(u);
  for (int v : adj[u]) {
    if (!mark[v]) {
      dfs(v, path);
    }
  }
}
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= m; ++i) {
    int cnt, v;
    for (scanf("%d", &cnt); cnt-- > 0;) {
      scanf("%d", &v);
      cl[i].emplace_back(v);
      adj[abs(v)].emplace_back(n + i);
      adj[n + i].emplace_back(abs(v));
    }
  }
  vector<vector<int>> ways;
  for (int deg = 0; deg <= 2; ++deg) {
    for (int start = 1; start <= n + m; ++start)
      if (!mark[start] && adj[start].size() == deg) {
        vector<int> path;
        vector<int> newWays(2, 0);
        dfs(start, path);
        if (deg == 0) {
          newWays[0] = 2;
          newWays[1] = 0;
        } else {
          vector<int> vid, cid;
          int head = path[0] > n ? cl[path[0] - n][0] : 0;
          int tail =
              path.back() > n && path.size() > 1 ? cl[path.back() - n][0] : 0;
          for (int i = 0; i < path.size(); ++i) {
            int a = path[i];
            if (a <= n) {
              vid.emplace_back(a);
              if (i + 1 < path.size()) {
                int id = path[i + 1] - n;
                if (cl[id].size() == 2) {
                  int b = path[(i + 2) % path.size()];
                  if (abs(cl[id][0]) != a) {
                    reverse(cl[id].begin(), cl[id].end());
                  }
                  cid.emplace_back(id);
                }
              }
            }
          }
          const int len = vid.size();
          for (int sv = 0; sv < 2; ++sv) {
            for (int i = 0; i < len; ++i) {
              for (int v = 0; v < 2; ++v) {
                for (int sum = 0; sum < 2; ++sum) {
                  dp[i][v][sum] = 0;
                }
              }
            }
            dp[0][sv][0] = 1;
            for (int i = 0; i + 1 < len; ++i) {
              for (int v = 0; v < 2; ++v) {
                for (int sum = 0; sum < 2; ++sum) {
                  for (int vv = 0; vv < 2; ++vv) {
                    int s = 0;
                    if (cl[cid[i]][0] < 0) {
                      s |= v ^ 1;
                    } else {
                      s |= v;
                    }
                    if (cl[cid[i]][1] < 0) {
                      s |= vv ^ 1;
                    } else {
                      s |= vv;
                    }
                    (dp[i + 1][vv][sum ^ s] += dp[i][v][sum]) %= mod;
                  }
                }
              }
            }
            for (int v = 0; v < 2; ++v) {
              for (int sum = 0; sum < 2; ++sum) {
                if (deg == 1) {
                  int finalSum = sum;
                  if (head > 0) {
                    finalSum ^= sv;
                  } else if (head < 0) {
                    finalSum ^= sv ^ 1;
                  }
                  if (tail > 0) {
                    finalSum ^= v;
                  } else if (tail < 0) {
                    finalSum ^= v ^ 1;
                  }
                  (newWays[finalSum] += dp[len - 1][v][sum]) %= mod;
                } else {
                  int s = 0;
                  if (cl[cid.back()][0] < 0) {
                    s |= v ^ 1;
                  } else {
                    s |= v;
                  }
                  if (cl[cid.back()][1] < 0) {
                    s |= sv ^ 1;
                  } else {
                    s |= sv;
                  }
                  (newWays[sum ^ s] += dp[len - 1][v][sum]) %= mod;
                }
              }
            }
          }
        }
        ways.emplace_back(newWays);
      }
  }
  memset(dp2, 0, sizeof dp2);
  dp2[0][0] = 1;
  for (int i = 0; i < ways.size(); ++i) {
    for (int sum = 0; sum < 2; ++sum) {
      for (int s = 0; s < 2; ++s) {
        (dp2[i + 1][sum ^ s] += (long long)dp2[i][sum] * ways[i][s] % mod) %=
            mod;
      }
    }
  }
  cout << dp2[ways.size()][1] << endl;
}
