import java.io.*;
import java.util.*;

public class RagnarScanner {
    public static void main(String[] args) throws IOException {
        // Create stdin buffered reader
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = sc.nextInt();
        int q = sc.nextInt();
        int m = sc.nextInt();
        int[] p = new int[n], t = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt() + 1;
        }
        int[][] hop = new int[18][n];
        int r = 0;
        for (int i = 0; i < n; i++) {
            while (r < n - 1 && p[r + 1] <= p[i] + m) {
                r++;
            }
            hop[0][i] = r;
        }
        for (int l = 1; l < 18; l++) {
            for (int i = 0; i < n; i++) {
                hop[l][i] = hop[l - 1][hop[l - 1][i]];
            }
        }
        int inf = 2 * 1000000000;
        int[] jumpleft = new int[n];
        int best = t[0];
        for (int i = 0; i < n; i++) {
            jumpleft[i] = Math.min(t[i], best + 1);
            best = Math.min(t[i], best);
        }
        int[] jumpright = new int[n];
        jumpright[n - 1] = t[n - 1];
        best = n - 1;
        for (int i = n - 2; i >= 0; i--) {
            int h = numHops(i, best, hop, inf);
            if (h == inf) {
                best = i;
                jumpright[i] = t[i];
                continue;
            }
            int viabest = numHops(i, best, hop, inf) + jumpright[best];
            if (t[i] < viabest) {
                jumpright[i] = t[i];
                best = i;
            } else {
                jumpright[i] = viabest;
            }
        }
        // Create a buffered reader to read query lines
        for (int i = 0; i < q; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            if (x < y) {
                System.out.println(1);
                continue;
            }
            System.out.println(Math.min(numHops(x, y, hop, inf), Math.min(jumpleft[y], jumpright[y])));
        }
    }

    private static int numHops(int i, int j, int[][] hop, int inf) {
        int h;
        if (i > j) {
            int temp = i;
            i = j;
            j = temp;
        }
        if (hop[17][i] < j) {
            return inf;
        }
        h = 0;
        for (int l = 17; l >= 0; l--) {
            if (hop[l][i] < j) {
                h += 1 << l;
                i = hop[l][i];
            }
        }
        assert i < j;
        i = hop[0][i];
        h++;
        assert i >= j;
        return h;
    }
}
