#include <bits/stdc++.h>
using namespace std;
int a[1000052], b[1000005];
int dp[4005][105][2];
const long long mod = 1e9 + 7;
int main() {
  int n, m, y, x, i, j, k, t;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  for (i = 1; i <= n; i++) {
    dp[a[i]][i][0]++;
    if (b[i] != a[i]) {
      dp[b[i]][i][1]++;
    }
  }
  for (i = 1; i < m; i++) {
    for (j = 1; j <= n; j++) {
      for (k = 1; k <= n; k++) {
        if (k != j) {
          if (a[k] == b[j]) {
            dp[i + a[k]][k][0] += dp[i][j][0];
            dp[i + a[k]][k][0] %= mod;
          }
          if (a[k] != b[k] && b[k] == b[j]) {
            dp[i + b[k]][k][1] += dp[i][j][0];
            dp[i + b[k]][k][1] %= mod;
          }
          if (a[k] == a[j]) {
            dp[i + a[k]][k][0] += dp[i][j][1];
            dp[i + a[k]][k][0] %= mod;
          }
          if (a[k] != b[k] && b[k] == a[j]) {
            dp[i + b[k]][k][1] += dp[i][j][1];
            dp[i + b[k]][k][1] %= mod;
          }
        }
      }
    }
  }
  long long ans = 0;
  for (i = 1; i <= n; i++) {
    ans += dp[m][i][0] + dp[m][i][1];
  }
  memset(dp, 0, sizeof(dp));
  printf("%I64d\n", ans % mod);
  return 0;
}
