#include <bits/stdc++.h>
using namespace std;
int dp[3333][111][2];
const int MOD = int(1e9 + 7);
int main() {
  int n, L;
  cin >> n >> L;
  vector<int> a(n), b(n);
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) cin >> a[i] >> b[i];
  memset(dp, 0, sizeof(dp));
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) {
    ++dp[a[i]][i][0];
    if (a[i] != b[i]) ++dp[b[i]][i][1];
  }
  for (int l = 0; l <= L; ++l)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        if (i != j) {
          if (a[j] == b[i]) {
            dp[l + a[j]][j][0] += dp[l][i][0];
            dp[l + a[j]][j][0] %= MOD;
          }
          if (a[j] == a[i]) {
            dp[l + a[j]][j][0] += dp[l][i][1];
            dp[l + a[j]][j][0] %= MOD;
          }
          if (a[j] != b[j] && b[j] == b[i]) {
            dp[l + b[j]][j][1] += dp[l][i][0];
            dp[l + b[j]][j][1] %= MOD;
          }
          if (a[j] != b[j] && b[j] == a[i]) {
            dp[l + b[j]][j][1] += dp[l][i][1];
            dp[l + b[j]][j][1] %= MOD;
          }
        }
  int ans = 0;
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) {
    ans += dp[L][i][0];
    ans %= MOD;
    ans += dp[L][i][1];
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
