#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

#define TESTPATH "D:\\Work\\C\\Debug\\"

	struct {
		int len;
		int used;
	} peaces[40];

	int total_peaces;
	int total_used = 0;
	int min_used = 1000;
	int finx, finy;

void find_solution_y(int y)
{
	if (total_used >= min_used) return;
	if (y > 1000 || y < 1) return;
	if (y == finy) {
		if (total_used < min_used) min_used = total_used;
	}

	for (int i = 0; i < total_peaces; i++) {
		if (!peaces[i].used) {
			peaces[i].used = 1; total_used++;

			find_solution_y(y + peaces[i].len);
			find_solution_y(y - peaces[i].len);

			peaces[i].used = 0; total_used--;
		}
	}
}

void find_solution_x(int x, int y)
{
	if (total_used >= min_used) return;
	if (x > 1000 || y > 1000 || x < 1 || y < 1) return;

	if (x == finx) {
		if (total_used < min_used) find_solution_y(y);
	}

	for (int i = 0; i < total_peaces; i++) {
		if (!peaces[i].used) {
			peaces[i].used = 1; total_used++;

			find_solution_x(x + peaces[i].len, y);
			find_solution_x(x - peaces[i].len, y);

			peaces[i].used = 0; total_used--;
		}
	}
}

int main(void)
{
	FILE * inf = fopen(TESTPATH"input.txt", "rt");
	FILE * outf = fopen(TESTPATH"output.txt", "wt");

	int k;
	int L[40], C[40];
	
	int i,j;
	int x0, y0;

	fscanf(inf, "%d", &x0);
	fscanf(inf, "%d", &y0);
	fscanf(inf, "%d", &finx);
	fscanf(inf, "%d", &finy);
	fscanf(inf, "%d", &k);

	for (i = 0; i < k; i++) fscanf(inf, "%d", &L[i]);
	for (i = 0; i < k; i++) fscanf(inf, "%d", &C[i]);

	total_peaces = 0;
	for (i = 0; i < k; i++) {
		for (j = 0; j < C[i]; j++) {
			peaces[total_peaces].len = L[i];
			peaces[total_peaces].used = 0;
			total_peaces++;
		}
	}

	find_solution_x(x0, y0);

	if (min_used <= 40) {
		fprintf(outf, "%d", min_used);
	} else {
		fprintf(outf, "%d", -1);
	}

	fclose(inf);
	fclose(outf);
	return 0;
}