#include <bits/stdc++.h>
using namespace std;
int n, l;
int arr[101][2] = {0};
long long dp[3001][101][2] = {-1};
long long solve(int width, int remainL, int index) {
  if (remainL == 0) {
    return 1;
  }
  int x = (width == arr[index][0]) ? 0 : 1;
  if (dp[remainL][index][x] != -1) return dp[remainL][index][x];
  long long val = 0;
  for (int i = 0; i < n; i++) {
    if (index == i) continue;
    if (arr[i][0] == width && remainL - arr[i][0] >= 0) {
      val += solve(arr[i][1], remainL - arr[i][0], i);
    }
    if (arr[i][0] == arr[i][1])
      ;
    else if (arr[i][1] == width && remainL - arr[i][1] >= 0) {
      val += solve(arr[i][0], remainL - arr[i][1], i);
    }
  }
  return dp[remainL][index][x] = val % 1000000007;
}
int main() {
  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    cin >> arr[i][0] >> arr[i][1];
  }
  for (int i = 0; i <= l; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i][j][0] = dp[i][j][1] = -1;
    }
  }
  long long val = 0;
  for (int i = 0; i < n; i++) {
    if (l - arr[i][1] >= 0) val += solve(arr[i][0], l - arr[i][1], i);
    if (arr[i][0] != arr[i][1] && l - arr[i][0] >= 0)
      val += solve(arr[i][1], l - arr[i][0], i);
  }
  cout << val % 1000000007;
  return 0;
}
