#include <bits/stdc++.h>
using namespace std;
const int MAXN = 120, MAXL = 3e3 + 20;
const long long P = 1e9 + 7;
int n;
long long w[MAXN], h[MAXN], d[MAXL][MAXN][2];
int main() {
  int l;
  scanf("%d%d", &n, &l);
  for (int i = 0; i < n; i++) scanf("%d%d", &w[i], &h[i]);
  for (int i = 1; i <= l; i++)
    for (int j = 0; j < n; j++) {
      if (w[j] == i) d[i][j][0] = 1;
      if (w[j] != h[j] && h[j] == i) d[i][j][1] = 1;
      for (int k = 0; k < n; k++) {
        if (j == k) continue;
        if (w[j] == h[k] && i >= w[j])
          d[i][j][0] = (d[i][j][0] + d[i - w[j]][k][0]) % P;
        if (w[j] == w[k] && i >= w[j])
          d[i][j][0] = (d[i][j][0] + d[i - w[j]][k][1]) % P;
        if (w[j] != h[j] && i >= h[j]) {
          if (h[j] == h[k]) d[i][j][1] = (d[i][j][1] + d[i - h[j]][k][0]) % P;
          if (h[j] == w[k]) d[i][j][1] = (d[i][j][1] + d[i - h[j]][k][1]) % P;
        }
      }
    }
  long long ans = 0;
  for (int i = 0; i < n; i++) ans = (ans + d[l][i][0] + d[l][i][1]) % P;
  printf("%lld\n", ans);
}
