#include <bits/stdc++.h>
using namespace std;
int N, L;
int boards[100][2];
int dp[3010][100][2];
const int md = 1000000007;
int getdp(int i, int prev, int pos) {
  if (i < 0) return 0;
  if (i == 0) return 1;
  int &res = dp[i][prev][pos];
  if (res != -1) return res;
  int prevl = boards[prev][pos];
  res = 0;
  for (int j = 0; j < N; j++) {
    if (j == prev) continue;
    for (int k = 0; k < 2; k++) {
      if (k == 1 && boards[j][0] == boards[j][1]) break;
      int len = boards[j][k];
      int wid = boards[j][1 - k];
      if (wid != prevl) continue;
      res += getdp(i - len, j, k);
      res %= md;
    }
  }
  return res;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> N >> L;
  for (int i = 0; i < N; i++) {
    cin >> boards[i][0] >> boards[i][1];
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      if (j == 1 && boards[i][0] == boards[i][1]) break;
      ans += getdp(L - boards[i][j], i, j);
      ans %= md;
    }
  }
  cout << ans << endl;
}
