#include <bits/stdc++.h>
using namespace std;
struct _ {
  _() { ios_base::sync_with_stdio(0); }
} _;
template <class A, class B>
ostream &operator<<(ostream &o, pair<A, B> t) {
  o << "(" << t.first << ", " << t.second << ")";
  return o;
}
template <class T>
void PV(T a, T b) {
  while (a != b) cout << *a++, cout << (a != b ? " " : "\n");
}
template <class T>
inline bool chmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
inline bool chmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
string tostring(T first, int len = 0) {
  stringstream ss;
  ss << first;
  string r = ss.str();
  if (r.length() < len) r = string(len - r.length(), '0') + r;
  return r;
}
template <class T>
void convert(string first, T &r) {
  stringstream ss(first);
  ss >> r;
}
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 111111;
int n, L;
int a[110];
int b[110];
int d[222][222];
int w[222];
int can[222];
int s[222][3333];
int used[222][3333];
vector<pair<int, int> > v;
int cnt;
void dfs(int id, int tot) {
  if (tot > L) return;
  if (tot == L) {
    cout << ++cnt << ": ";
    PV((v).begin(), (v).end());
    return;
  }
  for (int i = 0; i < n; i++) {
    if (id == i) continue;
    if (a[i] != b[i] && v.rbegin()->second == b[i]) {
      v.push_back(make_pair(b[i], a[i]));
      dfs(i, tot + b[i]);
      v.pop_back();
    }
    if (v.rbegin()->second == a[i]) {
      v.push_back(make_pair(a[i], b[i]));
      dfs(i, tot + a[i]);
      v.pop_back();
    }
  }
}
int main() {
  cin >> n >> L;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    can[2 * i] = 1;
    w[2 * i] = a[i];
    w[2 * i + 1] = b[i];
    if (a[i] != b[i]) can[2 * i + 1] = 1;
  }
  for (int i = 0; i < 2 * n; i++)
    for (int j = 0; j < 2 * n; j++) {
      if (i / 2 == j / 2 || !can[i] || !can[j]) continue;
      if (w[i ^ 1] == w[j]) d[i][j] = 1;
    }
  for (int i = 0; i < 2 * n; i++) {
    if (can[i]) d[2 * n][i] = 1;
  }
  priority_queue<pair<int, int> > Q;
  Q.push(make_pair(0, 2 * n));
  s[2 * n][0] = 1;
  while (!Q.empty()) {
    pair<int, int> cur = Q.top();
    Q.pop();
    int id = cur.second;
    int len = -cur.first;
    for (int i = 0; i < 2 * n; i++) {
      if (!d[id][i]) continue;
      int nextLen = len + w[i];
      if (nextLen > L) continue;
      if (s[i][nextLen] == 0) Q.push(make_pair(-nextLen, i));
      s[i][nextLen] += s[id][len];
      if (s[i][nextLen] >= mod) s[i][nextLen] -= mod;
    }
  }
  int res = 0;
  for (int i = 0; i <= 2 * n; i++) {
    res += s[i][L];
    if (res >= mod) res -= mod;
  }
  cout << res << endl;
  return 0;
}
