#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000 * 1000 * 1000 + 7;
const int maxl = 3000 + 100, maxn = 100 + 10;
long long dp[maxl][maxn][2];
int a[maxn][2];
int main() {
  ios_base::sync_with_stdio(false);
  int n, first;
  cin >> n >> first;
  for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1];
  for (int l = 1; l <= first; l++)
    for (int i = 0; i < n; i++)
      for (int p = 0; p < 2 - (a[i][0] == a[i][1]); p++) {
        if (l == a[i][p]) {
          dp[l][i][p] = 1;
          continue;
        }
        for (int j = 0; j < n; j++)
          if (i != j)
            for (int q = 0; q < 2 - (a[j][0] == a[j][1]); q++)
              if (a[i][p] == a[j][q] && l >= a[i][p]) {
                dp[l][i][p] =
                    (dp[l][i][p] +
                     dp[l - a[i][p]][j][q ^ (1 & (a[j][0] != a[j][1]))]) %
                    mod;
              }
      }
  long long res = 0;
  for (int i = 0; i < n; i++)
    for (int p = 0; p < 2; p++) res = (res + dp[first][i][p]) % mod;
  cout << res << endl;
}
