#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<list>
#include <cstring>
#include <functional>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF ((Int)1<<60)
#define EPS (1e-10)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define RREP(i,n) for(int i=1; i<=(int)(n); ++i)
typedef long long Int;
typedef pair<Int, Int> PI;
typedef pair<int, int> pi;
typedef tuple<int, int, int> TP;
typedef vector<double> vec;
typedef vector<vec> mat;
const int N = 201005;
//////////////////////////////

void solve()
{
	Int n, x;
	cin >> n >> x;
	vector<Int> a(n), b(n);
	REP(i, n) cin >> a[i];
	REP(i, n - 1) b[i] = (x%a[i + 1]) / a[i];
	
	Int dp[51][2] = { 0 };
	dp[0][0] = 1;
	REP(i, n) {
		dp[i + 1][0] += dp[i][0];
		if(b[i] == 0) dp[i + 1][1] += dp[i][1];

		if (b[i]) dp[i + 1][1] += dp[i][1] + dp[i][0];

		if (i == n - 1 || b[i] != a[i + 1] / a[i] - 1) dp[i + 1][0] += dp[i][1];
	}
	cout << dp[n][0] << endl;
}

int main() {
	solve();
	return 0;
}
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 2*1e5+10;

int a[MAX], b[MAX], p[MAX], q[MAX];
vector<P> ans;
int n;

bool solve() {
    rep(i,n) {
        if (p[i] == i) continue;
        int now = i, start = i, mn = b[p[i]];
        while (q[now] != i) {
            if (chmin(mn, b[p[q[now]]])) start = q[now];
            now = q[now];
        }
        auto f = [&](int now) {
            if (a[now] <= b[p[now]]) return false;
            if (a[q[now]] <= b[p[q[now]]]) return false;
            ans.push_back(P(now + 1, q[now] + 1));
            swap(p[now], p[q[now]]);
            return true;
        };
        while (p[start] != start) {
            if (!f(start)) return false;
            start = q[start];
        }
    }
    return true;
}

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) {
        cin >> p[i];
        p[i]--;
    }
    rep(i,n) q[p[i]] = i;
    if (!solve()) cout << -1 << endl;
    else {
        cout << (int)ans.size() << endl;
        rep(i,ans.size()) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
}