#include <bits/stdc++.h>
using namespace std;
const int con = 1e5;
const long long mod = 1000000007;
int main() {
  int n, l;
  cin >> n >> l;
  vector<vector<int> > nab(n);
  for (int i = 0; i < n; i++) {
    nab[i].resize(2);
    cin >> nab[i][0] >> nab[i][1];
  }
  vector<vector<vector<int> > > dp(l + 1 + con);
  for (int i = 0; i < con; i++) {
    dp[i].resize(2);
    for (int j = 0; j < 2; j++) {
      dp[i][j].assign(n, 0);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      dp[nab[i][j ^ 1]][j][i] = 1;
      if (nab[i][j] == nab[i][j ^ 1]) break;
    }
  }
  for (int i = 1; i <= l; i++) {
    for (int j = 0; j < n; j++) {
      for (int q = 0; q < 2; q++) {
        for (int k = 0; k < n; k++) {
          for (int pol = 0; pol < 2 && (pol < 1 || nab[k][1] != nab[k][0]);
               pol++) {
            if (nab[j][q] == nab[k][pol] && j != k) {
              dp[i + nab[k][pol]][pol ^ 1][k] += dp[i][q][j];
              dp[i + nab[k][pol]][pol ^ 1][k] %= mod;
            }
          }
        }
      }
    }
  }
  long long sol = 0LL;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) sol = (sol + dp[l][j][i]) % mod;
  }
  cout << sol;
  return 0;
}
