#include <bits/stdc++.h>
const int MOD = 1000000007;
int n, lim;
int x[2][200];
int dp[120][2][3040];
bool done[120][2][3040];
int f(int lst, int tp, int left) {
  if (left == 0) return 1;
  if (done[lst][tp][left]) return dp[lst][tp][left];
  int rn = 0;
  done[lst][tp][left] = 1;
  for (int i = 0; i < n; i++) {
    if (i != lst) {
      if (x[0][i] == x[tp][lst] && x[0][i] <= left)
        rn = (rn + f(i, 1, left - x[0][i])) % MOD;
      if (x[1][i] != x[0][i] && x[1][i] == x[tp][lst] && x[1][i] <= left)
        rn = (rn + f(i, 0, left - x[1][i])) % MOD;
    }
  }
  dp[lst][tp][left] = rn;
  return dp[lst][tp][left];
}
int main() {
  while (~scanf("%d %d", &n, &lim)) {
    for (int i = 0; i < n; i++) scanf("%d %d", &x[0][i], &x[1][i]);
    memset(done, 0, sizeof(done));
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (x[0][i] <= lim) ans = (ans + f(i, 1, lim - x[0][i])) % MOD;
      if (x[0][i] != x[1][i] && x[1][i] <= lim)
        ans = (ans + f(i, 0, lim - x[1][i])) % MOD;
    }
    printf("%d\n", ans);
  }
  return 0;
}
