#include <bits/stdc++.h>
const int M = 1000000000 + 7;
int n, l, a[2][100];
int dp[30001][100][2], res = 0;
int main() {
  scanf("%d %d", &n, &l);
  for (int i = 0; i < n; ++i) scanf("%d %d", &a[0][i], &a[1][i]);
  for (int i = 1; i <= l; ++i)
    for (int k = 0; k < n; ++k)
      for (int p = 0, P = a[0][k] == a[1][k] ? 1 : 2; p < P; ++p)
        if (i == a[p][k])
          dp[i][k][p] = 1;
        else if (i > a[p][k]) {
          dp[i][k][p] = 0;
          for (int j = 0; j < n; ++j)
            if (k != j)
              for (int q = 0; q < 2; ++q)
                if (a[(q + 1) % 2][j] == a[p][k])
                  dp[i][k][p] = (dp[i][k][p] + dp[i - a[p][k]][j][q]) % M;
        }
  for (int i = 0; i < n; ++i) res = (res + (dp[l][i][0] + dp[l][i][1]) % M) % M;
  printf("%d\n", res);
  return 0;
}
