#include <bits/stdc++.h>
using namespace std;
int sz, length;
const long long moduolo = 1e9 + 7;
vector<vector<int>> boards(100, vector<int>(2, 0));
vector<vector<vector<long long>>> DP(
    2, vector<vector<long long>>(101, vector<long long>(1e4, -1)));
long long solve(int index, int so_far, bool f) {
  f = !f;
  if (DP[f][index][so_far] != -1) {
    return DP[f][index][so_far];
  }
  if (so_far == length) {
    return DP[f][index][so_far] = 1;
  }
  if (so_far > length) {
    return DP[f][index][so_far] = 0;
  }
  if (index == sz) {
    return DP[f][index][so_far] = 0;
  }
  long long ret = 0;
  for (int i = 0; i < sz; i++) {
    if (i == index) {
      continue;
    }
    for (int j = 0; j < 2; j++) {
      if (boards[index][f] == boards[i][j]) {
        ret += solve(i, so_far + boards[i][j], j);
        ret %= moduolo;
      }
      if (boards[i][0] == boards[i][1]) {
        break;
      }
    }
  }
  return DP[f][index][so_far] = ret;
}
int main() {
  cin >> sz >> length;
  for (int i = 0; i < sz; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> boards[i][j];
    }
  }
  long long res = 0;
  for (int i = 0; i < sz; i++) {
    for (int j = 0; j < 2; j++) {
      res += solve(i, boards[i][j], j);
      res %= moduolo;
      if (boards[i][0] == boards[i][1]) {
        break;
      }
    }
  }
  cout << res << endl;
  return 0;
}
