#include <bits/stdc++.h>
using namespace std;
int ni() {
  int a;
  scanf("%d", &a);
  return a;
}
double nf() {
  double a;
  scanf("%lf", &a);
  return a;
}
char sbuf[100005];
string ns() {
  scanf("%s", sbuf);
  return sbuf;
}
long long nll() {
  long long a;
  scanf("%lld", &a);
  return a;
}
template <class T>
void out(T a, T b) {
  bool first = true;
  for (T i = a; i != b; ++i) {
    if (!first) printf(" ");
    first = false;
    cout << *i;
  }
  printf("\n");
}
template <class T>
void outl(T a, T b) {
  for (T i = a; i != b; ++i) {
    cout << *i << "\n";
  }
}
int n, m;
const int mod = 1000000007;
int d[3105][105][3];
int a[105], b[105];
int main() {
  int i, j, k;
  n = ni();
  m = ni();
  for (i = (0); i < (((n))); ++i) {
    a[i] = ni();
    b[i] = ni();
  }
  for (i = (0); i < (((n))); ++i) {
    d[b[i]][i][0] = 1;
    if (a[i] != b[i]) d[a[i]][i][1] = 1;
  }
  int ans = 0;
  for (i = (0); i < (((m + 1))); ++i)
    for (j = (0); j < (((n))); ++j)
      for (k = (0); k < (((2))); ++k)
        if (d[i][j][k]) {
          if (i == m) (ans += d[i][j][k]) %= mod;
          int lastW = (k ? b[j] : a[j]);
          int z, zz;
          for (z = (0); z < ((n)); ++z)
            if (z != j)
              for (zz = (0); zz < ((2)); ++zz) {
                if (zz == 0 && b[z] == lastW)
                  (d[i + b[z]][z][zz] += d[i][j][k]) %= mod;
                if (zz == 1 && a[z] == lastW && a[z] != b[z])
                  (d[i + a[z]][z][zz] += d[i][j][k]) %= mod;
              }
        }
  printf("%d\n", ans);
  return 0;
}
