#include <bits/stdc++.h>
using namespace std;
const int SN = 100 + 10;
const int SM = 3000 + 10;
const int MOD = 1000000007;
long long f[SN][SM][2], n, len, a[SN], b[SN], ans;
void Read(long long &x) {
  long long in = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    in = in * 10 + ch - '0';
    ch = getchar();
  }
  x = in * f;
}
int main() {
  Read(n), Read(len);
  for (int i = 1; i <= n; i++) Read(a[i]), Read(b[i]);
  for (int i = 1; i <= n; i++) {
    f[i][a[i]][0]++;
    if (a[i] != b[i]) f[i][b[i]][1]++;
  }
  for (int k = 1; k <= len; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        if (i == j) continue;
        if (k - a[i] >= 0) {
          if (a[i] == b[j]) f[i][k][0] = (f[i][k][0] + f[j][k - a[i]][0]) % MOD;
          if (a[i] == a[j] && a[j] != b[j])
            f[i][k][0] = (f[i][k][0] + f[j][k - a[i]][1]) % MOD;
        }
        if (a[i] == b[i]) continue;
        if (k - b[i] >= 0) {
          if (b[i] == b[j]) f[i][k][1] = (f[i][k][1] + f[j][k - b[i]][0]) % MOD;
          if (b[i] == a[j] && b[j] != a[j])
            f[i][k][1] = (f[i][k][1] + f[j][k - b[i]][1]) % MOD;
        }
      }
  for (int i = 1; i <= n; i++)
    if (a[i] != b[i])
      ans = (ans + f[i][len][1] + f[i][len][0]) % MOD;
    else
      ans = (ans + f[i][len][0]) % MOD;
  printf("%lld\n", ans);
  return 0;
}
