#include <bits/stdc++.h>
const int maxn = 305;
const int Mod = 1000000007;
int dp[5000][maxn];
int a[maxn], b[maxn], t[maxn];
int n, l;
int main() {
  int i, j, k;
  scanf("%d%d", &n, &l);
  k = n;
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    t[i] = i;
    if (a[i] != b[i]) {
      a[++k] = b[i];
      b[k] = a[i];
      t[k] = i;
    }
  }
  n = k;
  for (i = 1; i <= n; i++) dp[a[i]][i] = 1;
  for (i = 0; i <= l; i++) {
    for (j = 1; j <= n; j++) {
      if (!dp[i][j]) continue;
      for (k = 1; k <= n; k++) {
        if (t[j] == t[k]) continue;
        if (a[k] == b[j]) dp[i + a[k]][k] = (dp[i + a[k]][k] + dp[i][j]) % Mod;
      }
    }
  }
  int ans = 0;
  for (i = 1; i <= n; i++) ans = (ans + dp[l][i]) % Mod;
  printf("%d\n", ans);
  return 0;
}
