#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
int n, l, a[128][2], t[4096][128][2], w;
int main(void) {
  scanf("%d %d", &n, &l);
  for (int i = 0; i < n; ++i) scanf("%d %d", &a[i][0], &a[i][1]);
  for (int i = 0; i < 128; ++i)
    for (int j = (a[i][0] == a[i][1]) ? 1 : 2; j-- > 0;) t[a[i][j]][i][j] = 1;
  for (int i = 0; i < l; ++i)
    for (int j = 0; j < n; ++j)
      for (int k = 0; k < 2; ++k)
        if (t[i][j][k])
          for (int u = 0; u < n; ++u)
            if (u != j)
              for (int v = (a[u][0] == a[u][1]) ? 1 : 2; v-- > 0;)
                if (a[j][1 - k] == a[u][v] &&
                    (t[i + a[u][v]][u][v] += t[i][j][k]) >= Mod)
                  t[i + a[u][v]][u][v] -= Mod;
  for (int i = 0; i < n; ++i) (((w += t[l][i][0]) %= Mod) += t[l][i][1]) %= Mod;
  printf("%d\n", w);
  return 0;
}
