#include <bits/stdc++.h>
using namespace std;
const int md = 1000000007;
int n, len;
int z;
int h[200], w[200];
bool ok[200];
vector<int> widthmap[110];
void addmd(int &a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
  if (a < 0) {
    a += md;
  }
}
int gettot(int, int);
int getdp(int, int);
int dptot[3010][110];
int gettot(int len, int width) {
  if (len < 0) return 0;
  int &res = dptot[len][width];
  if (res != -1) return res;
  res = 0;
  for (int i = 0; i < (widthmap[width].size()); i++) {
    addmd(res, getdp(len, widthmap[width][i]));
  }
  return res;
}
int dp[3010][210];
int getdp(int len, int i) {
  int plen = len - h[i];
  if (plen < 0) return 0;
  if (plen == 0) return 1;
  int &res = dp[len][i];
  if (res != -1) return res;
  res = 0;
  addmd(res, gettot(plen, h[i]));
  int oth = (i / 2) * 2 + 1 - (i % 2);
  if (w[i] == h[i]) {
    addmd(res, -getdp(plen, i));
  } else {
    addmd(res, -getdp(plen, oth));
  }
  return res;
}
int main() {
  memset(dptot, -1, sizeof(dptot));
  memset(dp, -1, sizeof(dp));
  cin >> n >> len;
  for (int i = 0; i < (n); i++) {
    cin >> h[z] >> w[z];
    ok[z] = true;
    z++;
    h[z] = w[z - 1];
    w[z] = h[z - 1];
    ok[z] = (h[z] != w[z]);
    z++;
  }
  for (int i = 0; i < (z); i++) {
    if (ok[i]) {
      widthmap[w[i]].push_back(i);
    }
  }
  int res = 0;
  for (int i = 0; i < (z); i++) {
    if (ok[i]) {
      addmd(res, getdp(len, i));
    }
  }
  cout << res;
}
