#include <bits/stdc++.h>
using namespace std;
int t[3001][101][2];
int dim[2][100];
int n;
int f(int L, int last, int ori) {
  if (L == 0) return 1;
  int &ret = t[L][last][ori];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = 0; i < n; ++i)
    if (i != last) {
      if (dim[0][i] == dim[ori][last] && dim[0][i] <= L)
        ret = (ret + f(L - dim[0][i], i, 1)) % 1000000007;
      if (dim[1][i] != dim[0][i] && dim[1][i] == dim[ori][last] &&
          dim[1][i] <= L)
        ret = (ret + f(L - dim[1][i], i, 0)) % 1000000007;
    }
  return ret;
}
int main() {
  memset(t, -1, sizeof(t));
  int L, res = 0;
  cin >> n >> L;
  for (int i = 0; i < n; ++i) cin >> dim[0][i] >> dim[1][i];
  for (int i = 0; i < n; ++i) {
    if (dim[0][i] <= L) res = (res + f(L - dim[0][i], i, 1)) % 1000000007;
    if (dim[1][i] != dim[0][i] && dim[1][i] <= L)
      res = (res + f(L - dim[1][i], i, 0)) % 1000000007;
  }
  cout << res << "\n";
}
