#include <bits/stdc++.h>
using namespace std;
long long n, l;
long long aa[128], bb[128];
long long dp[3008][128][2];
int main() {
  cin >> n >> l;
  for (long long i = 1; i <= n; i++) cin >> aa[i] >> bb[i];
  memset(dp, 0, sizeof dp);
  for (long long len = 1; len <= l; len++) {
    for (long long k = 1; k <= n; k++) {
      long long a = aa[k];
      long long b = bb[k];
      if (len - a >= 0) {
        if (len - a == 0) {
          dp[len][k][0] += 1;
        }
        long long &ref = dp[len][k][0];
        for (long long i = 1; i <= n; i++) {
          if (i == k) continue;
          if (a == bb[i]) {
            ref += dp[len - a][i][0];
            ref %= 1000000007;
          }
          if (a == aa[i] && aa[i] != bb[i]) {
            ref += dp[len - a][i][1];
            ref %= 1000000007;
          }
        }
      }
      if (a == b) {
        dp[len][k][1] = dp[len][k][0];
        continue;
      }
      if (len - b >= 0) {
        if (len - b == 0) {
          dp[len][k][1] += 1;
        }
        long long &ref = dp[len][k][1];
        for (long long i = 1; i <= n; i++) {
          if (i == k) continue;
          if (b == bb[i]) {
            ref += dp[len - b][i][0];
            ref %= 1000000007;
          }
          if (b == aa[i] && aa[i] != bb[i]) {
            ref += dp[len - b][i][1];
            ref %= 1000000007;
          }
        }
      }
    }
  }
  long long res = 0;
  for (long long i = 1; i <= n; i++) {
    res += dp[l][i][0];
    res %= 1000000007;
    if (aa[i] != bb[i]) {
      res += dp[l][i][1];
      res %= 1000000007;
    }
  }
  cout << res % 1000000007 << endl;
  return 0;
}
