#include <bits/stdc++.h>
const int N = 3200;
using namespace std;
int n, l;
int a[N][3], b[N][3];
int dp[N][105][3];
void add(int &a, int &b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> l;
  for (int i = 1; i <= n; i++) {
    cin >> a[i][0] >> b[i][0];
    a[i][1] = b[i][0];
    b[i][1] = a[i][0];
  }
  for (int i = 1; i <= n; i++) {
    dp[a[i][0]][i][0] += 1;
    if (a[i][0] != b[i][0]) dp[b[i][0]][i][1] += 1;
  }
  for (int i = 1; i <= l; i++) {
    for (int cur = 1; cur <= n; cur++) {
      for (int rot1 = 0; rot1 <= 1; rot1++) {
        for (int to = 1; to <= n; to++) {
          if (to != cur)
            for (int rot2 = 0; rot2 <= 1; rot2++) {
              if (a[to][0] == b[to][0] && rot2 == 1) continue;
              if (b[cur][rot1] == a[to][rot2])
                add(dp[i + a[to][rot2]][to][rot2], dp[i][cur][rot1]);
            }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 1; j++) {
      add(ans, dp[l][i][j]);
    }
  }
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
