import java.util.Scanner;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int i, j, k;
int a=sc.nextInt(); int[] A = new int[a];
int b=sc.nextInt(); int[] B = new int[b];
int x = sc.nextInt();
int[] C = new int[a*b]; // kinds of A+B
// input A and B
for (i=0; i<a; i++) A[i] = sc.nextInt();
for (j=0; j<a; j++) B[j] = sc.nextInt();
k=0; // input A+B into C
for (i=0; i<a; i++){
for (j=0; j<b; j++){
C[k] = A[i] + B[j];
k++;
}
}
int diff = Math.abs(x-C[0]);
for (k=1; k<a*b; k++){
if (diff > Math.abs(x-C[k])){
diff = Math.abs(x-C[k]);
}
}
System.out.println(diff);
}
}
왜 롱앤서50까지인지 도저히 갈피를 못 잡겠습니다