#include <bits/stdc++.h>
using namespace std;
const long d3 = 1000;
const long d4 = 10000;
const long d5 = 100000;
const long d6 = 1000000;
const long d7 = 10000000;
const long d8 = 100000000;
const long d9 = 1000000000;
const long long MOD = d9 + 7;
int main() {
  long n, l, a[100], b[100];
  long long dp[3501][101][2];
  for (int i = 0; i < 3501; i++) {
    for (int j = 0; j < 101; j++) {
      for (int z = 0; z < 2; z++) {
        dp[i][j][z] = 0;
      }
    }
  }
  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  long w;
  for (int i = 0; i < n; i++) {
    dp[b[i]][i][0] = 1;
    if (b[i] != a[i]) {
      dp[a[i]][i][1] = 1;
    }
  }
  for (int i = 0; i < l; i++) {
    for (int j = 0; j < n; j++) {
      w = a[j];
      for (int z = 0; z < n; z++) {
        if (z != j) {
          if (b[z] == w) {
            dp[i + w][z][0] = (dp[i + w][z][0] + dp[i][j][0]) % MOD;
          } else {
            if (a[z] == w) {
              dp[i + w][z][1] = (dp[i + w][z][1] + dp[i][j][0]) % MOD;
            }
          }
        }
      }
      w = b[j];
      for (int z = 0; z < n; z++) {
        if (z != j) {
          if (b[z] == w) {
            dp[i + w][z][0] = (dp[i + w][z][0] + dp[i][j][1]) % MOD;
          } else {
            if (a[z] == w) {
              dp[i + w][z][1] = (dp[i + w][z][1] + dp[i][j][1]) % MOD;
            }
          }
        }
      }
    }
  }
  long long answ = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      answ = (answ + dp[l][i][j]) % MOD;
    }
  }
  cout << answ;
  return 0;
}
