#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l, a[101], b[101], res = 0, F[3003][101][2];
  scanf("%d%d", &n, &l);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i], &b[i]);
  for (int i = 1; i <= l; i++)
    for (int j = 1; j <= n; j++) {
      if (a[j] == i)
        F[i][j][0] = 1;
      else if (a[j] < i) {
        F[i][j][0] = 0;
        for (int k = 1; k <= n; k++)
          if (k != j) {
            if (b[k] == a[j])
              F[i][j][0] = (F[i][j][0] + F[i - a[j]][k][0]) % 1000000007;
            if (a[k] != b[k] && a[k] == a[j])
              F[i][j][0] = (F[i][j][0] + F[i - a[j]][k][1]) % 1000000007;
          }
      }
      if (a[j] == b[j]) {
        F[i][j][1] = 0;
        continue;
      }
      if (b[j] == i)
        F[i][j][1] = 1;
      else if (b[j] <= i) {
        F[i][j][1] = 0;
        for (int k = 1; k <= n; k++)
          if (k != j) {
            if (b[k] == b[j])
              F[i][j][1] = (F[i][j][1] + F[i - b[j]][k][0]) % 1000000007;
            if (a[k] != b[k] && a[k] == b[j])
              F[i][j][1] = (F[i][j][1] + F[i - b[j]][k][1]) % 1000000007;
          }
      }
    }
  for (int i = 1; i <= n; i++)
    res = ((res + F[l][i][0]) % 1000000007 + F[l][i][1]) % 1000000007;
  printf("%d\n", res);
  return 0;
}
