#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} a[100500], ans[100500];
int go[100500], now, tot;
int cmp(node a, node b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}
void solve(int x) {
  ans[++tot].x = now;
  ans[tot].y = x;
  swap(go[now], go[x]);
  now = x;
}
int main(void) {
  int n, x, lucky = -1;
  cin >> n;
  tot = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].x);
    a[i].y = i;
    x = a[i].x;
    int flag = 1;
    while (x) {
      if (x % 10 != 4 && x % 10 != 7) flag = 0;
      x /= 10;
    }
    if (flag) lucky = i;
  }
  sort(a + 1, a + 1 + n, cmp);
  for (int i = 1; i <= n; i++) go[a[i].y] = i;
  if (lucky == -1) {
    for (int i = 1; i <= n; i++)
      if (go[i] != i) {
        cout << -1 << endl;
        return 0;
      }
  }
  now = lucky;
  while (1) {
    int flag = 1;
    for (int i = 1; i <= n; i++) {
      if (now == i) continue;
      if (go[i] != i) {
        flag = 0;
        if (go[i] == now)
          solve(i);
        else {
          solve(go[i]);
          solve(i);
        }
      }
    }
    if (flag) break;
  }
  cout << tot << endl;
  for (int i = 1; i <= tot; i++) printf("%d %d\n", ans[i].x, ans[i].y);
  return 0;
}
