#include <bits/stdc++.h>
using namespace std;
const int Mx = 256, Mod = 1000 * 1000 * 1000 + 7;
vector<pair<int, int>> V, N[Mx];
int dp[4096][Mx];
void add(int x, int y, int b) {
  int id = V.size();
  V.push_back({x, y});
  for (int i = 0; i < id - b; i++) {
    if (V[i].second == x) N[id].push_back({i, x});
    if (V[i].first == y) N[i].push_back({id, y});
  }
}
int main() {
  int n, l, a = 0;
  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    add(x, y, 0);
    if (x != y) add(y, x, 1);
  }
  for (int i = 0; i < V.size(); i++) dp[V[i].first][i] = 1;
  for (int i = 1; i <= l; i++)
    for (int j = 0; j < V.size(); j++)
      for (auto p : N[j])
        if (p.second <= i)
          dp[i][j] = (dp[i][j] + dp[i - p.second][p.first]) % Mod;
  for (int i = 0; i < V.size(); i++) a = (a + dp[l][i]) % Mod;
  cout << a;
}
