#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007LL;
int n, l;
long long a[102], b[102];
long long dp[2 * 3002][102][2];
int main() {
  while (cin >> n >> l) {
    for (int i = 0; i < n; ++i) {
      cin >> a[i] >> b[i];
    }
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < n; ++i) {
      dp[a[i]][i][0] = 1LL;
      if (a[i] != b[i]) {
        dp[b[i]][i][1] = 1LL;
      }
    }
    for (int i = 1; i <= l; ++i) {
      for (int j = 0; j < n; ++j) {
        if (dp[i][j][0]) {
          for (int k = 0; k < n; ++k) {
            if (k != j) {
              if (a[k] == b[j]) {
                dp[i + b[j]][k][0] = (dp[i + b[j]][k][0] + dp[i][j][0]) % mod;
              } else if (b[k] == b[j]) {
                dp[i + b[j]][k][1] = (dp[i + b[j]][k][1] + dp[i][j][0]) % mod;
              }
            }
          }
        }
        if (dp[i][j][1]) {
          for (int k = 0; k < n; ++k) {
            if (k != j) {
              if (a[k] == a[j]) {
                dp[i + a[j]][k][0] = (dp[i + a[j]][k][0] + dp[i][j][1]) % mod;
              } else if (b[k] == a[j]) {
                dp[i + a[j]][k][1] = (dp[i + a[j]][k][1] + dp[i][j][1]) % mod;
              }
            }
          }
        }
      }
    }
    long long ans = 0LL;
    for (int i = 0; i < n; ++i) {
      ans = (ans + dp[l][i][0]) % mod;
      ans = (ans + dp[l][i][1]) % mod;
    }
    cout << ans << endl;
  }
  return 0;
}
