#pragma comment(linker,"/STACK:64000000")
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <sstream>
#include <cmath>
#include <ctime>
#include <memory.h>

#define WR printf
#define RE scanf
#define PB push_back
#define SE second
#define FI first
#define MP make_pair

#define FOR(i,Be,En) for(int (i)=(Be);(i)<=(En);++(i))
#define DFOR(i,Be,En) for(int (i)=(Be);(i)>=(En);--(i))
#define SZ(a) (int)((a).size())
#define FA(i,v) FOR(i,0,SZ(v)-1)
#define RFA(i,v) DFOR(i,SZ(v)-1,0)
#define CLR(a) memset(a,0,sizeof(a))

#define LL  long long
#define VI  vector<int>
#define PAR pair<int ,int> 

using namespace std;
void __never(int a){printf("\nOPS %d", a);}
void __die(int a){printf("%d",(a*a)/(a+a));}
#define ass(s) {if (!(s)) {__never(__LINE__);cout.flush();cerr.flush();__die(0);}}



#define MN 1000500
const int inf = 1e9;


int n, k;
int x[MN];
int rx[MN];
int ans[MN];

int bans[MN];

int le1, ri1, le2, ri2;
int best;


int bbans[MN];
int bbest = inf;
int id = -1;

int MAX_ITS;
int its;
void dfs(int shag, int cost, int L1, int R1, int L2, int R2) {

	/*
	FOR(i,0,shag-1){
		WR("%d",ans[i]);
	}
	WR("\n");
	*/
	
	if (++its > MAX_ITS) return ;
	
	if (shag == n) {
		if (cost < best) {
			best = cost;
			FOR(i,0,n-1) bans[i] = ans[i];
		}
		return ;
	}

	int m[2];
	if (ans[shag-1] == 1) m[0] = 2, m[1] = 1;
	else m[0] = 1, m[1] = 2;
	
	FOR(i,0,1) {
		if (++its > MAX_ITS) return;
		int h = m[i];
		if (h == 1) {
			if (L1 <= x[shag] && x[shag] <= R1) {
				ans[shag] = h;
				dfs(shag+1, cost + (ans[shag] == ans[shag-1] ? 1 : 0), x[shag] + le1, x[shag] + ri1, L2, R2);
			}
		} else {
			if (L2 <= x[shag] && x[shag] <= R2) {
				ans[shag] = h;
				dfs(shag+1, cost + (ans[shag] == ans[shag-1] ? 1 : 0), L1, R1, x[shag] + le2, x[shag] + ri2);
			}
		}
	}
}


void solve_test(int num){
	
	RE("%d %d %d %d", &le1, &ri1, &le2, &ri2);
	
	best = inf;
	its = 0;
	ans[0] = 1;
	dfs(1, 0, x[0] + le1, x[0] + ri1, -(1<<30), (1<<30));
	if (best < bbest) {
		bbest = best;
		FOR(i,0,n-1) bbans[i] = bans[i];
		id = num;
	}
	
	
	best = inf;
	its = 0;
	ans[0] = 2;
	dfs(1, 0, -(1<<30), (1<<30), x[0] + le2, x[0] + ri2);
	if (best < bbest) {
		bbest = best;
		FOR(i,0,n-1) bbans[i] = bans[i];
		id = num;
	}
	
	FOR(i,0,n-1) swap(x[i], rx[i]);
	
	best = inf;
	its = 0;
	ans[0] = 1;
	dfs(1, 0, x[0] + le1, x[0] + ri1, -(1<<30), (1<<30));
	if (best < bbest) {
		bbest = best;
		FOR(i,0,n-1) bbans[i] = bans[n-i-1];
		id = num;
	}
	
	best = inf;
	its = 0;
	ans[0] = 2;
	dfs(1, 0, -(1<<30), (1<<30), x[0] + le2, x[0] + ri2);
	if (best < bbest) {
		bbest = best;
		FOR(i,0,n-1) bbans[i] = bans[n-i-1];
		id = num;
	}
	
	FOR(i,0,n-1) swap(x[i], rx[i]);
	
}

void init()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
}
void sol(){	
	freopen("dynasties.in", "r", stdin);
	freopen("dynasties.out", "w", stdout);
	RE("%d",&n);
	FOR(i,0,n-1) RE("%d",&x[i]);
	FOR(i,0,n-1) rx[i] = -x[n-i-1];
	
	
	bbest = inf;
	RE("%d",&k);
	MAX_ITS = 20000000 / k;
	FOR(i,1,k) solve_test(i);
	
	if (id == -1) {
		WR("0\n");
	} else {
		WR("%d %d\n", id, bbest);
		FOR(i,0,n-1) WR("%d",bbans[i]);
	}
	//cerr << clock() << endl;
}
int main()
{
	init();
	sol();
	return 0;
}