#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
const long long MX = 2e5 + 5;
const long long INF = 1e18;
const long double PI = 4 * atan((long double)1);
long long power_md(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) res = (res % md * a % md) % md;
    a = (a % md * a % md) % md;
    n /= 2;
  }
  res %= md;
  return res;
}
long long power(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) res *= a;
    a = a * a;
    n /= 2;
  }
  return res;
}
long long abst(long long a) { return ((a < 0) ? (-1 * a) : (a)); }
class cmp_set {
 public:
  bool operator()(long long a, long long b) { return a > b; }
};
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while (!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) long long idx,
               __attribute__((unused)) long long LINE_NUM) {
  cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, long long idx, long long LINE_NUM, Head H,
               Tail... T) {
  if (idx > 0)
    cerr << ", ";
  else
    cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
long long n, len;
long long li[105], wi[105];
long long dp[105][3005][2];
long long fun(long long prev, long long l, long long rot) {
  if (l < 0)
    return 0;
  else if (l == 0)
    return 1;
  if (dp[prev][l][rot] != -1) return dp[prev][l][rot];
  long long res = 0;
  long long wp;
  if (prev == 0)
    wp = -1;
  else {
    if (rot)
      wp = li[prev];
    else
      wp = wi[prev];
  }
  for (long long i = 1; i <= n; i++) {
    if (i == prev) continue;
    if (wp == -1) {
      res = (res % md + fun(i, l - li[i], (long long)0) % md) % md;
      if (wi[i] != li[i])
        res = (res % md + fun(i, l - wi[i], (long long)1) % md) % md;
    } else {
      if (li[i] == wp)
        res = (res % md + fun(i, l - li[i], (long long)0) % md) % md;
      if ((wi[i] == wp) && (wi[i] != li[i]))
        res = (res % md + fun(i, l - wi[i], (long long)1) % md) % md;
    }
  }
  return dp[prev][l][rot] = res;
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  memset(dp, -1, sizeof(dp));
  cin >> n >> len;
  for (long long i = 1; i <= n; i++) {
    cin >> li[i] >> wi[i];
  }
  long long res = fun((long long)0, len, (long long)0) % md;
  cout << res << "\n";
  return 0;
}
