#include <bits/stdc++.h>
using namespace std;
const int maxn = 210;
const int mod = 1e9 + 7;
const int maxl = 3e3 + 10;
int ans;
int n, l;
int dp[maxn][maxl];
vector<int> bois[maxn], things, oof;
void in();
void solve();
void out();
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  in();
  solve();
  out();
}
void in() {
  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    bois[a].push_back(i * 2);
    things.push_back(b);
    oof.push_back(a);
    if (b != a) {
      bois[b].push_back(i * 2 + 1);
      things.push_back(a);
      oof.push_back(b);
    } else {
      things.push_back(-1);
      oof.push_back(-1);
    }
  }
}
void solve() {
  for (int i = 0; i <= things.size(); i++) dp[i][0] = 1;
  for (int j = 1; j <= l; j++)
    for (int i = 0; i < things.size(); i++)
      if (things[i] != -1)
        for (auto x : bois[things[i]])
          if (j - things[i] >= 0 && (i ^ 1) != x && i != x)
            dp[i][j] = (dp[i][j] + dp[x][j - things[i]]) % mod;
  for (int i = 0; i < things.size(); i++)
    if (things[i] != -1)
      if (l - oof[i] >= 0) ans = (ans + dp[i][l - oof[i]]) % mod;
}
void out() { cout << ans; }
