#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
map<int, set<int> > M;
vector<pair<int, int> > V;
const int MOD = 1000000007;
int l;
int index(int i, int v) { return ((V[i].first == v) ? 0 : 1); }
int other(int i, int v) {
  return ((V[i].first == v) ? V[i].second : V[i].first);
}
int main() {
  ios::sync_with_stdio(false);
  cout.precision(20);
  int n;
  cin >> n >> l;
  vector<vector<vector<int> > > dp(l + 1,
                                   vector<vector<int> >(n, vector<int>(2, 0)));
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    V.push_back(make_pair(a, b));
    M[a].insert(i);
    M[b].insert(i);
    if (a <= l) dp[a][i][0] = 1;
    if (a != b && b <= l) dp[b][i][1] = 1;
  }
  for (int i = 1; i < l; ++i) {
    for (int j = 0; j < n; j++) {
      for (int h = 0; h < 2; h++) {
        if (dp[i][j][h] > 0) {
          int x = (h == 0) ? V[j].second : V[j].first;
          if (x + i <= l) {
            for (int m : M[x]) {
              if (m != j) {
                dp[i + x][m][index(m, x)] += dp[i][j][h];
                dp[i + x][m][index(m, x)] %= MOD;
              }
            }
          }
        }
      }
    }
  }
  int result = 0;
  for (int i = 0; i < n; ++i) {
    result += dp[l][i][0];
    result %= MOD;
    result += dp[l][i][1];
    result %= MOD;
  }
  cout << result << endl;
  return 0;
}
