#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000000 + 7;
const long long int N = 10000000 + 6;
long long int dp[3001][101][2];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, l;
  cin >> n >> l;
  long long int h[n + 1], w[n + 1];
  for (int i = 1; i <= n; i++) cin >> h[i] >> w[i];
  for (int j = 1; j <= n; j++) {
    dp[h[j]][j][0] = 1;
    if (w[j] != h[j]) dp[w[j]][j][1] = 1;
  }
  for (int i = 1; i <= l; i++) {
    for (int j = 1; j <= n; j++) {
      int llength = i - h[j];
      int lwidth = h[j];
      if (llength > 0) {
        for (int k = 1; k <= n; k++) {
          if (k == j) continue;
          if (h[k] == lwidth)
            dp[i][j][0] = (dp[i][j][0] + dp[llength][k][1]) % mod;
          if (w[k] == lwidth)
            dp[i][j][0] = (dp[i][j][0] + dp[llength][k][0]) % mod;
        }
      }
      if (h[j] != w[j]) {
        llength = i - w[j];
        lwidth = w[j];
        if (llength > 0) {
          for (int k = 1; k <= n; k++) {
            if (k == j) continue;
            if (h[k] == lwidth)
              dp[i][j][1] = (dp[i][j][1] + dp[llength][k][1]) % mod;
            if (w[k] == lwidth)
              dp[i][j][1] = (dp[i][j][1] + dp[llength][k][0]) % mod;
          }
        }
      }
    }
  }
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = (ans + dp[l][i][0]) % mod;
    if (h[i] != w[i]) ans = (ans + dp[l][i][1]) % mod;
  }
  cout << ans;
  return 0;
}
