#include <bits/stdc++.h>
using namespace std;
int dp[3002][102][2];
int a[102], b[102];
int main() {
  int n, l, i, j, k;
  cin >> n >> l;
  for (i = 0; i < n; i++) cin >> a[i] >> b[i];
  memset(dp, 0, sizeof(dp));
  for (i = 1; i <= l; i++)
    for (j = 0; j < n; j++) {
      if (a[j] == i) dp[i][j][0]++;
      if (b[j] == i) dp[i][j][1]++;
    }
  for (i = 1; i <= l; i++)
    for (j = 0; j < n; j++)
      for (k = 0; k < n; k++) {
        if (j == k) continue;
        if (a[j] == a[k] && i > a[j] && dp[i - a[j]][k][1])
          dp[i][j][0] = (dp[i][j][0] + dp[i - a[j]][k][1]) % 1000000007;
        if (a[j] == b[k] && i > a[j] && a[k] != b[k] && dp[i - a[j]][k][0])
          dp[i][j][0] = (dp[i][j][0] + dp[i - a[j]][k][0]) % 1000000007;
        if (b[j] == b[k] && i > b[j] && dp[i - b[j]][k][0])
          dp[i][j][1] = (dp[i][j][1] + dp[i - b[j]][k][0]) % 1000000007;
        if (b[j] == a[k] && i > b[j] && a[k] != b[k] && dp[i - b[j]][k][1])
          dp[i][j][1] = (dp[i][j][1] + dp[i - b[j]][k][1]) % 1000000007;
      }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    ans = (ans + dp[l][i][0]) % 1000000007;
    if (a[i] != b[i]) ans = (ans + dp[l][i][1]) % 1000000007;
  }
  cout << ans;
  return 0;
}
