#include <bits/stdc++.h>
using namespace std;
const int maxix = 3000 + 10;
pair<int, int> arr[110];
int dp[maxix][110][2];
const int mod = 1000 * 1000 * 1000 + 7;
int main() {
  int n, l;
  cin >> n >> l;
  for (int i = 0; i < n; i++) cin >> arr[i].first >> arr[i].second;
  int finalans = 0;
  for (int i = 1; i <= l; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (arr[j].first == i)
          dp[i][j][0] = 1;
        else if (k != j && i - arr[j].first >= 0) {
          if (arr[k].first == arr[j].first)
            dp[i][j][0] = (dp[i][j][0] + dp[i - arr[j].first][k][1]) % mod;
          else if (arr[k].second == arr[j].first)
            dp[i][j][0] = (dp[i][j][0] + dp[i - arr[j].first][k][0]) % mod;
        }
        if (arr[j].second == i)
          dp[i][j][1] = 1;
        else if (k != j && i - arr[j].second >= 0) {
          if (arr[k].first == arr[j].second)
            dp[i][j][1] = (dp[i][j][1] + dp[i - arr[j].second][k][1]) % mod;
          else if (arr[k].second == arr[j].second)
            dp[i][j][1] = (dp[i][j][1] + dp[i - arr[j].second][k][0]) % mod;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (arr[i].first != arr[i].second)
      finalans = (finalans + ((dp[l][i][0] + dp[l][i][1]) % mod)) % mod;
    else
      finalans = (finalans + max(dp[l][i][1], dp[l][i][0])) % mod;
  }
  cout << finalans % mod;
  return 0;
}
