Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cinema is at the point s.There are k gas stations along the road, and at each of them you can fill a car with any amount of fuel for free! Consider that this operation doesn't take any time, i.e. is carried out instantly.There are n cars in the rental service, i-th of them is characterized with two integers ci and vi — the price of this car rent and the capacity of its fuel tank in liters. It's not allowed to fuel a car with more fuel than its tank capacity vi. All cars are completely fueled at the car rental service.Each of the cars can be driven in one of two speed modes: normal or accelerated. In the normal mode a car covers 1 kilometer in 2 minutes, and consumes 1 liter of fuel. In the accelerated mode a car covers 1 kilometer in 1 minutes, but consumes 2 liters of fuel. The driving mode can be changed at any moment and any number of times.Your task is to choose a car with minimum price such that Vasya can reach the cinema before the show starts, i.e. not later than in t minutes. Assume that all cars are completely fueled initially.

The first line contains four positive integers n, k, s and t (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 2·105, 2 ≤ s ≤ 109, 1 ≤ t ≤ 2·109) — the number of cars at the car rental service, the number of gas stations along the road, the length of the road and the time in which the film starts.  Each of the next n lines contains two positive integers ci and vi (1 ≤ ci, vi ≤ 109) — the price of the i-th car and its fuel tank capacity. The next line contains k distinct integers g1, g2, ..., gk (1 ≤ gi ≤ s - 1) — the positions of the gas stations on the road in arbitrary order.

Print the minimum rent price of an appropriate car, i.e. such car that Vasya will be able to reach the cinema before the film starts (not later than in t minutes). If there is no appropriate car, print -1.

NoteIn the first sample, Vasya can reach the cinema in time using the first or the third cars, but it would be cheaper to choose the first one. Its price is equal to 10, and the capacity of its fuel tank is 8. Then Vasya can drive to the first gas station in the accelerated mode in 3 minutes, spending 6 liters of fuel. After that he can full the tank and cover 2 kilometers in the normal mode in 4 minutes, spending 2 liters of fuel. Finally, he drives in the accelerated mode covering the remaining 3 kilometers in 3 minutes and spending 6 liters of fuel.

package main

import "fmt"
import "sort"
import "bufio"
import "os"

type Car struct {
	price    int
	tanksize int
}

type Cars []Car

func (slice Cars) Len() int {
	return len(slice)
}
func (slice Cars) Less(i, j int) bool {
	return slice[i].tanksize < slice[j].tanksize
}
func (slice Cars) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

func mymin(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func mymax(a, b int) int {
	return -mymin(-a, -b)
}
func canReach(tank, time int, stations *[]int) bool {
	from := 0
	n := len(*stations)
	for i := 0; i < n; i++ {
		s := (*stations)[i] - from
		if s > tank {
			return false
		}
		mintime := mymax(s, 2*s-(tank-s))
		time -= mintime
		from = (*stations)[i]
	}
	if time >= 0 {
		return true
	}
	return false
}

func main() {
	var n, k, s, t int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n, &k, &s, &t)
	n++
	cars := Cars(make([]Car, n))
	cars[n-1].tanksize = 1 << 30
	for i := 0; i < n-1; i++ {
		fmt.Fscan(in, &cars[i].price, &cars[i].tanksize)
	}

	stations := make([]int, k+1)
	for i := 0; i < k; i++ {
		fmt.Fscan(in, &stations[i])
	}
	stations[k] = s
	sort.Ints(stations)
	sort.Sort(cars)
	mintil := make([]int, n)
	mintil[n-2] = cars[n-2].price
	for i := n - 3; i >= 0; i-- {
		mintil[i] = mymin(mintil[i+1], cars[i].price)
	}
	a := 0
	b := n - 1
	for a < b {
		o := (a + b) / 2
		if canReach(cars[o].tanksize, t, &stations) {
			b = o
		} else {
			a = o + 1
		}
	}
	if a == n-1 {
		fmt.Println(-1)
	} else {
		fmt.Println(mintil[a])
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    my := func() int64 {
        sort.Sort(sort.Reverse(ByV(a)))
        cars := []Car{}
        for i := range a {
            if i == 0 || a[i].c < cars[len(cars)-1].c {
                cars = append(cars, a[i])
            }
        }

        l, r := 0, len(cars)-1
        for l < r {
            mid := (l+r+1) / 2
            if can(cars[mid].v) {
                l = mid
            } else {
                r = mid-1
            }
        }

        thisSol := int64(-1)
        if can(cars[l].v) {
            thisSol = cars[l].c
        }

        return thisSol;
    }

    fmt.Println(my())
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    ac := func() int64 {
        l, r := int64(0), int64(1<<32)
        for l < r {
            mid := (l+r)/2
            if can(mid) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        ok, ans := false, int64(0)
        for _, car := range a {
            if car.v >= r && (!ok || car.c < ans) {
                ans = car.c
                ok = true
            }
        }

        if ok {
            return ans
        }
        return -1
    }

    fail := func(sol int64) int64 {
        sort.Sort(ByV(a))
        cars := []Car{}
        for i := range a {
            if i == n-1 || a[i].c < a[i+1].c {
                cars = append(cars, a[i])
            }
        }

        indx := -1
        for i := range cars {
            if cars[i].c == sol {
                indx = i
            }
        }

        if indx < 0 && sol >= 0 {
            fmt.Println("NO FOUND")
        }

        return -1
    }

    sol := ac()
    fail(sol)

    fmt.Println(sol)
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))
    sort.Sort(ByV(a))
    cars := []Car{}
    for i := range a {
        if i == n-1 || a[i].c < a[i+1].c {
            cars = append(cars, a[i])
        }
    }

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    l, r := int64(0), int64(1<<32)
    for l < r {
        mid := (l+r)/2
        if can(mid) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    ok, ans := false, int64(0)
    for _, car := range a {
        if car.v >= r && (!ok || car.c < ans) {
            ans = car.c
            ok = true
        }
    }

    if ok {
        fmt.Println(ans)
    } else {
        fmt.Println(-1)
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    ac := func() int64 {
        l, r := int64(0), int64(1<<32)
        for l < r {
            mid := (l+r)/2
            if can(mid) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        ok, ans := false, int64(0)
        for _, car := range a {
            if car.v >= r && (!ok || car.c < ans) {
                ans = car.c
                ok = true
            }
        }

        if ok {
            return ans
        }
        return -1
    }

    fail := func() int64 {
        sort.Sort(ByV(a))
        cars := []Car{}
        for i := range a {
            if i == n-1 || a[i].c < a[i+1].c {
                cars = append(cars, a[i])
            }
        }

        return -1
    }

    fail()

    fmt.Println(ac())
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var bufin *bufio.Reader
var bufout *bufio.Writer

type Car struct {
	price, tank int64
}

type CarList []Car

func (a CarList) Len() int           { return len(a) }
func (a CarList) Less(i, j int) bool { return a[i].tank < a[j].tank }
func (a CarList) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type Int64Slice []int64

func (s Int64Slice) Len() int               { return len(s) }
func (s Int64Slice) Less(i int, j int) bool { return s[i] < s[j] }
func (s Int64Slice) Swap(i int, j int)      { s[i], s[j] = s[j], s[i] }

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

	var n, k int
	var s, t int64
	fmt.Fscanf(bufin, "%d %d %d %d\n", &n, &k, &s, &t)

	cars := make(CarList, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(bufin, "%d %d\n", &cars[i].price, &cars[i].tank)
	}
	sort.Sort(cars)

	g := make(Int64Slice, k+2)
	g[0] = 0
	g[k+1] = s
	for i := 1; i <= k; i++ {
		fmt.Fscanf(bufin, "%d\n", &g[i])
	}
	sort.Sort(g)

	roads := make(Int64Slice, k+1)
	for i := 0; i <= k; i++ {
		roads[i] = g[i+1] - g[i]
	}
	sort.Sort(roads)

	sum := make([]int64, k+2)
	for i := 1; i <= k+1; i++ {
		sum[i] = sum[i-1] + roads[i-1]
	}

	res := int64(-1)
	j := -1
	for i := 0; i < n; i++ {
		tank := cars[i].tank
		if tank >= roads[k] {
			for (j+1 <= k) && (2*roads[j+1] <= tank) {
				j++
			}
			t1 := sum[j+1]
			t2 := 3*(sum[k+1]-sum[j+1]) - tank*int64(k-j)
			totalTime := t1 + t2
			if totalTime <= t {
				if (res == -1) || (res > cars[i].price) {
					res = cars[i].price
				}
			}
		}
	}

	fmt.Fprintf(bufout, "%d\n", res)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    my := func() int64 {
        sort.Sort(sort.Reverse(ByV(a)))
        cars := []Car{}
        for i := range a {
            if i == 0 || a[i].c < a[i-1].c {
                cars = append(cars, a[i])
            }
        }

        l, r := 0, len(cars)-1
        for l < r {
            mid := (l+r+1) / 2
            if can(cars[mid].v) {
                l = mid
            } else {
                r = mid-1
            }
        }

        thisSol := int64(-1)
        if can(cars[l].v) {
            thisSol = cars[l].c
        }

        return thisSol;
    }

    fmt.Println(my())
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt(), readInt()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt(), readInt()}
    }
    g := append(readIntArray(k), s)
    sort.Ints(g)
    //sort.Sort(ByV(a))

    cars := []Car{}
    for i := range a {
        if i == n-1 || a[i].c < a[i+1].c {
            cars = append(cars, a[i])
        }
    }

    can := func(v int) bool {
        prev, tm := 0, int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := int64(min(d, v-d))
            x1 := int64(d)-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= int64(t)
    }

    l, r := 0, n+1
    mn, ok := r, false
    for l < r {
        mid := (l+r)/2
        if can(mid) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    for _, car := range a {
        if car.v >= r && car.c < mn {
            mn = car.c
            ok = true
        }
    }

    if ok {
        fmt.Println(mn)
    } else {
        fmt.Println(-1)
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readArray(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = readInt()
	}
	return res
}

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt(), readInt()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt(), readInt()}
    }
    g := append(readIntArray(k), s)
    sort.Ints(g)
    //sort.Sort(ByV(a))

    cars := []Car{}
    for i := range a {
        if i == n-1 || a[i].c < a[i+1].c {
            cars = append(cars, a[i])
        }
    }

    can := func(v int) bool {
        prev, tm := 0, int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := int64(min(d, v-d))
            x1 := int64(d)-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= int64(t)
    }

    l, r := 0, 2*(s+10)
    mn, ok := r, false
    for l < r {
        mid := (l+r)/2
        if can(mid) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    for _, car := range a {
        if car.v >= r && car.c < mn {
            mn = car.c
            ok = true
        }
    }

    if ok {
        fmt.Println(mn)
    } else {
        fmt.Println(-1)
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readArray(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = readInt()
	}
	return res
}

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    ac := func() int64 {
        l, r := int64(0), int64(1<<32)
        for l < r {
            mid := (l+r)/2
            if can(mid) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        ok, ans := false, int64(0)
        for _, car := range a {
            if car.v >= r && (!ok || car.c < ans) {
                ans = car.c
                ok = true
            }
        }

        if ok {
            return ans
        }
        return -1
    }

    fail := func(sol int64) int64 {
        sort.Sort(ByV(a))
        cars := []Car{}
        for i := range a {
            if i == n-1 || a[i].c < a[i+1].c {
                cars = append(cars, a[i])
            }
        }

        l, r := 0, len(cars)-1
        for l < r {
            mid := (l+r)/2
            if can(cars[mid].v) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        thisSol := int64(-1)
        if can(cars[r].v) {
            thisSol = cars[r].c
        }

        if thisSol != sol {
            fmt.Println(r, cars[r])
            for i := range cars {
                if sol == cars[i].c {
                    fmt.Println(i, cars[i])
                }
            }
        }

        return -1
    }

    sol := ac()
    if t == 312312312 {
        fail(sol)
    }

    fmt.Println(sol)
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    ac := func() int64 {
        l, r := int64(0), int64(1<<32)
        for l < r {
            mid := (l+r)/2
            if can(mid) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        ok, ans := false, int64(0)
        for _, car := range a {
            if car.v >= r && (!ok || car.c < ans) {
                ans = car.c
                ok = true
            }
        }

        if ok {
            return ans
        }
        return -1
    }

    fail := func(sol int64) int64 {
        sort.Sort(ByV(a))
        cars := []Car{}
        for i := range a {
            if i == n-1 || a[i].c < a[i+1].c {
                cars = append(cars, a[i])
            }
        }

        l, r := 0, len(cars)-1
        for l < r {
            mid := (l+r)/2
            if can(cars[mid].v) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        if a[r].c > sol {
            //fmt.Println(a[r-10:r+10])
            fmt.Println("FAIL")
        }

        return -1
    }

    sol := ac()
    fail(sol)

    fmt.Println(sol)
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt(), readInt()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt(), readInt()}
    }
    g := append(readIntArray(k), s)
    sort.Ints(g)
    //sort.Sort(ByV(a))

    cars := []Car{}
    for i := range a {
        if i == n-1 || a[i].c < a[i+1].c {
            cars = append(cars, a[i])
        }
    }

    can := func(v int) bool {
        prev, tm := 0, int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := int64(min(d, v-d))
            x1 := int64(d)-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= int64(t)
    }

    l, r := 0, 2*s
    mn, ok := r, false
    for l < r {
        mid := (l+r)/2
        if can(mid) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    for _, car := range a {
        if car.v >= r && car.c < mn {
            mn = car.c
            ok = true
        }
    }

    if ok {
        fmt.Println(mn)
    } else {
        fmt.Println(-1)
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readArray(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = readInt()
	}
	return res
}

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))
    sort.Sort(ByV(a))
    cars := []Car{}
    for i := range a {
        if i == n-1 || a[i].c < a[i+1].c {
            cars = append(cars, a[i])
        }
    }

    /*
    if t == 312312312 {
        fmt.Println(a[:20])
        fmt.Println(cars[:20])
    }
    */

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    l, r := 0, len(cars)-1
    for l < r {
        mid := (l+r)/2
        if can(cars[mid].v) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    if can(cars[r].v) {
        fmt.Println(cars[r].c)
    } else {
        fmt.Println(-1)
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    ac := func() int64 {
        l, r := int64(0), int64(1<<32)
        for l < r {
            mid := (l+r)/2
            if can(mid) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        ok, ans := false, int64(0)
        for _, car := range a {
            if car.v >= r && (!ok || car.c < ans) {
                ans = car.c
                ok = true
            }
        }

        if ok {
            return ans
        }
        return -1
    }

    fail := func(sol int64) int64 {
        sort.Sort(ByV(a))
        cars := []Car{}
        for i := range a {
            if i == n-1 || a[i].c < a[i+1].c {
                cars = append(cars, a[i])
            }
        }

        l, r := 0, len(cars)-1
        for l < r {
            mid := (l+r)/2
            if can(cars[mid].v) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        thisSol := int64(-1)
        if can(cars[r].v) {
            thisSol = cars[r].c
        }

        if thisSol != sol {
            fmt.Println(r)
            for i := range cars {
                if sol == cars[i].c {
                    fmt.Println(i)
                }
            }
        }

        return -1
    }

    sol := ac()
    fail(sol)

    fmt.Println(sol)
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))
    sort.Sort(ByV(a))
    cars := []Car{}
    for i := range a {
        if i == n-1 || a[i].c < a[i+1].c {
            cars = append(cars, a[i])
        }
    }

    if t == 312312312 {
        fmt.Println(a[len(a)-20:])
        fmt.Println(cars[len(cars)-20:])
    }

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    l, r := 0, len(cars)-1
    for l < r {
        mid := (l+r)/2
        if can(cars[mid].v) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    if can(cars[r].v) {
        fmt.Println(cars[r].c)
    } else {
        fmt.Println(-1)
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt(), readInt()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt(), readInt()}
    }
    g := append(readIntArray(k), s)
    sort.Ints(g)

    sort.Sort(ByV(a))
    cars := []Car{}
    for i := range a {
        if i == n-1 || a[i].c < a[i+1].c {
            cars = append(cars, a[i])
        }
    }

    if t == 312312312 {
        fmt.Println(a[:20])
        fmt.Println(cars[:20])
    }

    can := func(i int) bool {
        v, prev, tm := cars[i].v, 0, int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := int64(min(d, v-d))
            x1 := int64(d)-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= int64(t)
    }

    l, r := 0, len(cars)-1
    for l < r {
        mid := (l+r)/2
        if can(mid) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    if can(r) {
        fmt.Println(cars[r].c)
    } else {
        fmt.Println(-1)
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readArray(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = readInt()
	}
	return res
}

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt(), readInt()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt(), readInt()}
    }
    g := append(readIntArray(k), s)
    sort.Ints(g)
    sort.Sort(ByV(a))

    cars := []Car{}
    for i := range a {
        if i == n-1 || a[i].c < a[i+1].c {
            cars = append(cars, a[i])
        }
    }

    can := func(i int) bool {
        v, prev, tm := cars[i].v, 0, int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := int64(min(d, v-d))
            x1 := int64(d)-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= int64(t)
    }

    l, r := 0, len(cars)-1
    for l < r {
        mid := (l+r)/2
        if can(mid) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    if can(r) {
        fmt.Println(cars[r].c)
    } else {
        fmt.Println(-1)
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readArray(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = readInt()
	}
	return res
}

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    ac := func() int64 {
        l, r := int64(0), int64(1<<32)
        for l < r {
            mid := (l+r)/2
            if can(mid) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        ok, ans := false, int64(0)
        for _, car := range a {
            if car.v >= r && (!ok || car.c < ans) {
                ans = car.c
                ok = true
            }
        }

        if ok {
            return ans
        }
        return -1
    }

    fail := func(sol int64) int64 {
        sort.Sort(ByV(a))
        cars := []Car{}
        for i := range a {
            if i == n-1 || a[i].c < a[i+1].c {
                cars = append(cars, a[i])
            }
        }

        l, r := 0, len(cars)-1
        for l < r {
            mid := (l+r)/2
            if can(cars[mid].v) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        thisSol := int64(-1)
        if can(cars[r].v) {
            thisSol = cars[r].c
        }

        if thisSol != sol {
            fmt.Println(a[r-5:r+5])
            //fmt.Println("FAIL")
        }

        return -1
    }

    sol := ac()
    fail(sol)

    fmt.Println(sol)
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    ac := func() int64 {
        l, r := int64(0), int64(1<<32)
        for l < r {
            mid := (l+r)/2
            if can(mid) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        ok, ans := false, int64(0)
        for _, car := range a {
            if car.v >= r && (!ok || car.c < ans) {
                ans = car.c
                ok = true
            }
        }

        if ok {
            return ans
        }
        return -1
    }

    fail := func(sol int64) int64 {
        sort.Sort(ByV(a))
        cars := []Car{}
        for i := range a {
            if i == n-1 || a[i].c < a[i+1].c {
                cars = append(cars, a[i])
            }
        }

        l, r := 0, len(cars)-1
        for l < r {
            mid := (l+r)/2
            if can(cars[mid].v) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        thisSol := int64(-1)
        if can(cars[r].v) {
            thisSol = cars[r].c
        }

        if thisSol != sol {
            //fmt.Println(a[r-10:r+10])
            fmt.Println("FAIL")
        }

        return -1
    }

    sol := ac()
    fail(sol)

    fmt.Println(sol)
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int64
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt64(), readInt64()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt64(), readInt64()}
    }
    g := append(readInt64Array(k), s)

    sort.Sort(Ints64(g))

    can := func(v int64) bool {
        prev, tm := int64(0), int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := v-d
            if x2 > d {
                x2 = d
            }
            x1 := d-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= t
    }

    ac := func() int64 {
        l, r := int64(0), int64(1<<32)
        for l < r {
            mid := (l+r)/2
            if can(mid) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        ok, ans := false, int64(0)
        for _, car := range a {
            if car.v >= r && (!ok || car.c < ans) {
                ans = car.c
                ok = true
            }
        }

        if ok {
            return ans
        }
        return -1
    }

    fail := func(sol int64) int64 {
        sort.Sort(ByV(a))
        cars := []Car{}
        for i := range a {
            if i == n-1 || a[i].c < a[i+1].c {
                cars = append(cars, a[i])
            }
        }

        l, r := 0, len(cars)-1
        for l < r {
            mid := (l+r)/2
            if can(cars[mid].v) {
                r = mid
            } else {
                l = mid + 1
            }
        }

        thisSol := int64(-1)
        if can(cars[r].v) {
            thisSol = cars[r].c
        }

        if thisSol != sol {
            fmt.Println(r)
            for i := range cars {
                if sol == cars[i].c {
                    fmt.Println(i, cars[i])
                }
            }
        }

        return -1
    }

    sol := ac()
    if t == 312312312 {
        fail(sol)
    }

    fmt.Println(sol)
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64
func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt(), readInt()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt(), readInt()}
    }
    g := append(readIntArray(k), s)
    sort.Ints(g)
    sort.Sort(ByV(a))

    cars := []Car{}
    for i := range a {
        if i == n-1 || a[i].c < a[i+1].c {
            cars = append(cars, a[i])
        }
    }

    can := func(i int) bool {
        v, prev, tm := cars[i].v, 0, int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := int64(min(d, v-d))
            x1 := int64(d)-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= int64(t)
    }

    l, r := 0, len(cars)-1
    for l < r {
        mid := (l+r)/2
        if can(mid) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    if can(r) {
        fmt.Println(cars[l].c)
    } else {
        fmt.Println(-1)
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readArray(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = readInt()
	}
	return res
}

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt(), readInt()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt(), readInt()}
    }
    g := append(readIntArray(k), s)
    sort.Ints(g)

    sort.Sort(ByV(a))
    cars := []Car{}
    for i := range a {
        if i == n-1 || a[i].c < a[i+1].c {
            cars = append(cars, a[i])
        }
    }

    if t == 312312312 {
        fmt.Println(a[:10])
        fmt.Println(cars[:10])
    }

    can := func(i int) bool {
        v, prev, tm := cars[i].v, 0, int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := int64(min(d, v-d))
            x1 := int64(d)-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= int64(t)
    }

    l, r := 0, len(cars)-1
    for l < r {
        mid := (l+r)/2
        if can(mid) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    if can(r) {
        fmt.Println(cars[r].c)
    } else {
        fmt.Println(-1)
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readArray(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = readInt()
	}
	return res
}

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
    "sort"
	//"math"
)

type Car struct {
    c, v int
}

type ByV []Car
func (a ByV) Len() int           { return len(a) }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }

func solve() {
    n, k, s, t := readInt(), readInt(), readInt(), readInt()
    a := make([]Car, n)
    for i := range a {
        a[i] = Car{readInt(), readInt()}
    }
    g := append(readIntArray(k), s)
    sort.Ints(g)
    //sort.Sort(ByV(a))

    cars := []Car{}
    for i := range a {
        if i == n-1 || a[i].c < a[i+1].c {
            cars = append(cars, a[i])
        }
    }

    can := func(v int) bool {
        prev, tm := 0, int64(0)
        for _, st := range g {
            d := st - prev
            if d > v {
                return false
            }
            x2 := int64(min(d, v-d))
            x1 := int64(d)-x2
            tm += 2*x1 + x2
            prev = st
        }

        return tm <= int64(t)
    }

    l, r := 0, s+1
    mn, ok := r, false
    for l < r {
        mid := (l+r)/2
        if can(mid) {
            r = mid
        } else {
            l = mid + 1
        }
    }

    for _, car := range a {
        if car.v >= r && car.c < mn {
            mn = car.c
            ok = true
        }
    }

    if ok {
        fmt.Println(mn)
    } else {
        fmt.Println(-1)
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readArray(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = readInt()
	}
	return res
}

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

	var n, k, s, t int
	fmt.Fscanf(bufin, "%d %d %d %d\n", &n, &k, &s, &t)

	c := make([]int, n)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(bufin, "%d %d\n", &c[i], &v[i])
	}

	g := make([]int, k+2)
	g[0] = 0
	g[k+1] = s
	for i := 1; i <= k; i++ {
		fmt.Fscanf(bufin, "%d\n", &g[i])
	}
	sort.Ints(g)

	roads := make([]int, k+1)
	for i := 0; i <= k; i++ {
		roads[i] = g[i+1] - g[i]
	}
	sort.Ints(roads)

	sum := make([]int64, k+2)
	for i := 1; i <= k+1; i++ {
		sum[i] = sum[i-1] + int64(roads[i-1])
	}

	res := -1
	j := -1
	for i := 0; i < n; i++ {
		tank := v[i]
		if tank >= roads[k] {
			for (j+1 <= k) && (2*roads[j+1] <= tank) {
				j++
			}
			t1 := sum[j+1]
			t2 := 3*(sum[k+1]-sum[j+1]) - int64(tank)*int64(k-j)
			totalTime := t1 + t2
			if totalTime <= int64(t) {
				if (res == -1) || (res > c[i]) {
					res = c[i]
				}
			}
		}
	}

	fmt.Fprintf(bufout, "%d\n", res)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

	var n, k, s, t int
	fmt.Fscanf(bufin, "%d %d %d %d\n", &n, &k, &s, &t)

	c := make([]int, n)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(bufin, "%d %d\n", &c[i], &v[i])
	}

	g := make([]int, k+2)
	g[0] = 0
	g[k+1] = s
	for i := 1; i <= k; i++ {
		fmt.Fscanf(bufin, "%d\n", &g[i])
	}
	sort.Ints(g)

	roads := make([]int, k+1)
	for i := 0; i <= k; i++ {
		roads[i] = g[i+1] - g[i]
	}
	sort.Ints(roads)

	sum := make([]int, k+2)
	for i := 1; i <= k+1; i++ {
		sum[i] = sum[i-1] + roads[i-1]
	}

	res := -1
	j := -1
	for i := 0; i < n; i++ {
		tank := v[i]
		if tank >= roads[k] {
			for (j+1 <= k) && (2*roads[j+1] <= tank) {
				j++
			}
			t1 := sum[j+1]
			t2 := 3*(sum[k+1]-sum[j+1]) - tank*(k-j)
			totalTime := t1 + t2
			if totalTime <= t {
				if (res == -1) || (res > c[i]) {
					res = c[i]
				}
			}
		}
	}

	fmt.Fprintf(bufout, "%d\n", res)
}


Isart and Modsart were trying to solve an interesting problem when suddenly Kasra arrived. Breathless, he asked: "Can you solve a problem I'm stuck at all day?"We have a tree T with n vertices and m types of ice cream numerated from 1 to m. Each vertex i has a set of si types of ice cream. Vertices which have the i-th (1 ≤ i ≤ m) type of ice cream form a connected subgraph. We build a new graph G with m vertices. We put an edge between the v-th and the u-th (1 ≤ u, v ≤ m, u ≠ v) vertices in G if and only if there exists a vertex in T that has both the v-th and the u-th types of ice cream in its set. The problem is to paint the vertices of G with minimum possible number of colors in a way that no adjacent vertices have the same color.Please note that we consider that empty set of vertices form a connected subgraph in this problem.As usual, Modsart don't like to abandon the previous problem, so Isart wants you to solve the new problem.

The first line contains two integer n and m (1 ≤ n, m ≤ 3·105) — the number of vertices in T and the number of ice cream types. n lines follow, the i-th of these lines contain single integer si (0 ≤ si ≤ 3·105) and then si distinct integers, each between 1 and m — the types of ice cream in the i-th vertex. The sum of si doesn't exceed 5·105. n - 1 lines follow. Each of these lines describes an edge of the tree with two integers u and v (1 ≤ u, v ≤ n) — the indexes of connected by this edge vertices.

Print single integer c in the first line — the minimum number of colors to paint the vertices in graph G. In the second line print m integers, the i-th of which should be the color of the i-th vertex. The colors should be between 1 and c. If there are some answers, print any of them.

NoteIn the first example the first type of ice cream is present in the first vertex only, so we can color it in any color. The second and the third ice cream are both presented in the second vertex, so we should paint them in different colors.In the second example the colors of the second, the fourth and the fifth ice cream should obviously be distinct.

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

func main() {
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	n := readInt()
	m := readInt()
	s := make([][]int, n)
	bi := 0
	for i := range s {
		s[i] = make([]int, readInt())
		for j := range s[i] {
			s[i][j] = readInt() - 1
		}
		if len(s[bi]) < len(s[i]) {
			bi = i
		}
	}
	edges := make([][]int, n)
	for i := 1; i < n; i++ {
		v := readInt() - 1
		u := readInt() - 1
		edges[v] = append(edges[v], u)
		edges[u] = append(edges[u], v)
	}

	visited := make([]bool, n)
	visited[bi] = true

	res := make([]int, m)
	for i, ice := range s[bi] {
		res[ice] = i + 1
	}
	ans := len(s[bi])

	q := []int{bi}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		for _, u := range edges[v] {
			if visited[u] {
				continue
			}
			visited[u] = true
			q = append(q, u)

			var used []int
			for _, ice := range s[u] {
				if x := res[ice]; x > 0 {
					used = append(used, x)
				}
			}
			sort.Ints(used)

			try := 1
			for _, ice := range s[u] {
				if res[ice] > 0 {
					continue
				}
				for len(used) > 0 && used[0] == try {
					try++
					used = used[1:]
				}
				res[ice] = try
				if ans < try {
					ans = try
				}
				try++
			}
		}
	}

	if ans == 0 {
		ans = 1
	}
	fmt.Fprintln(out, ans)
	for i, c := range res {
		if c == 0 {
			c = 1
		}
		if i+1 == m {
			fmt.Fprintln(out, c)
		} else {
			fmt.Fprint(out, c, " ")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

func main() {
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	n := readInt()
	m := readInt()
	s := make([][]int, n)
	bi := 0
	for i := range s {
		s[i] = make([]int, readInt())
		for j := range s[i] {
			s[i][j] = readInt() - 1
		}
		if len(s[bi]) < len(s[i]) {
			bi = i
		}
	}
	edges := make([][]int, n)
	for i := 1; i < n; i++ {
		v := readInt() - 1
		u := readInt() - 1
		edges[v] = append(edges[v], u)
		edges[u] = append(edges[u], v)
	}

	visited := make([]bool, n)
	visited[bi] = true

	res := make([]int, m)
	for i, ice := range s[bi] {
		res[ice] = i + 1
	}
	ans := len(s[bi])

	q := []int{bi}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		used := make([]int, len(s[v]))
		for _, ice := range s[v] {
			used = append(used, res[ice])
		}
		sort.Ints(used)
		for _, u := range edges[v] {
			if visited[u] {
				continue
			}
			visited[u] = true
			q = append(q, u)

			try := 1
			used := used
			for _, ice := range s[u] {
				if res[ice] > 0 {
					continue
				}
				for len(used) > 0 && used[0] == try {
					try++
					used = used[1:]
				}
				res[ice] = try
				if ans < try {
					ans = try
				}
				try++
			}
		}
	}

	if ans == 0 {
		ans++
	}
	fmt.Fprintln(out, ans)
	for i, c := range res {
		if c == 0 {
			c = 1
		}
		if i+1 == m {
			fmt.Fprintln(out, c)
		} else {
			fmt.Fprint(out, c, " ")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

func main() {
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	n := readInt()
	m := readInt()
	s := make([][]int, n)
	bi := 0
	for i := range s {
		s[i] = make([]int, readInt())
		for j := range s[i] {
			s[i][j] = readInt() - 1
		}
		if len(s[bi]) < len(s[i]) {
			bi = i
		}
	}
	edges := make([][]int, n)
	for i := 1; i < n; i++ {
		v := readInt() - 1
		u := readInt() - 1
		edges[v] = append(edges[v], u)
		edges[u] = append(edges[u], v)
	}

	visited := make([]bool, n)
	visited[bi] = true

	res := make([]int, m)
	for i, ice := range s[bi] {
		res[ice] = i + 1
	}

	q := []int{bi}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		used := make([]int, len(s[v]))
		for _, ice := range s[v] {
			used = append(used, res[ice])
		}
		sort.Ints(used)
		for _, u := range edges[v] {
			if visited[u] {
				continue
			}
			visited[u] = true
			q = append(q, u)

			try := 1
			used := used
			for _, ice := range s[u] {
				if res[ice] > 0 {
					continue
				}
				for len(used) > 0 && used[0] == try {
					try++
					used = used[1:]
				}
				res[ice] = try
				try++
			}
		}
	}

	ans := len(s[bi])
	if ans == 0 {
		ans++
	}
	fmt.Fprintln(out, ans)
	for i, c := range res {
		if c == 0 {
			c = 1
		}
		if i+1 == m {
			fmt.Fprintln(out, c)
		} else {
			fmt.Fprint(out, c, " ")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

func main() {
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	n := readInt()
	m := readInt()
	s := make([][]int, n)
	bi := 0
	for i := range s {
		s[i] = make([]int, readInt())
		for j := range s[i] {
			s[i][j] = readInt() - 1
		}
		if len(s[bi]) < len(s[i]) {
			bi = i
		}
	}
	edges := make([][]int, n)
	for i := 1; i < n; i++ {
		v := readInt() - 1
		u := readInt() - 1
		edges[v] = append(edges[v], u)
		edges[u] = append(edges[u], v)
	}

	visited := make([]bool, n)
	visited[bi] = true

	res := make([]int, m)
	for i, ice := range s[bi] {
		res[ice] = i + 1
	}
	ans := len(s[bi])

	q := []int{bi}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		used := make([]int, len(s[v]))
		for _, ice := range s[v] {
			used = append(used, res[ice])
		}
		sort.Ints(used)
		for _, u := range edges[v] {
			if visited[u] {
				continue
			}
			visited[u] = true
			q = append(q, u)

			try := 1
			used := used
			for _, ice := range s[u] {
				if res[ice] > 0 {
					continue
				}
				for len(used) > 0 && used[0] == try {
					try++
					used = used[1:]
				}
				res[ice] = try
				if ans < try {
					ans = try
				}
				try++
			}
		}
	}

	fmt.Fprintln(out, ans)
	for i, c := range res {
		if c == 0 {
			c = 1
		}
		if i+1 == m {
			fmt.Fprintln(out, c)
		} else {
			fmt.Fprint(out, c, " ")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

func main() {
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	n := readInt()
	m := readInt()
	s := make([][]int, n)
	bi := 0
	for i := range s {
		s[i] = make([]int, readInt())
		for j := range s[i] {
			s[i][j] = readInt() - 1
		}
		if len(s[bi]) < len(s[i]) {
			bi = i
		}
	}
	edges := make([][]int, n)
	for i := 1; i < n; i++ {
		v := readInt() - 1
		u := readInt() - 1
		edges[v] = append(edges[v], u)
		edges[u] = append(edges[u], v)
	}

	visited := make([]bool, n)
	visited[bi] = true

	res := make([]int, m)
	for i, ice := range s[bi] {
		res[ice] = i + 1
	}

	q := []int{bi}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		used := make([]int, len(s[v]))
		for _, ice := range s[v] {
			used = append(used, res[ice])
		}
		sort.Ints(used)
		for _, u := range edges[v] {
			if visited[u] {
				continue
			}
			visited[u] = true
			q = append(q, u)

			try := 1
			used := used
			for _, ice := range s[u] {
				if res[ice] > 0 {
					continue
				}
				for len(used) > 0 && used[0] == try {
					try++
					used = used[1:]
				}
				res[ice] = try
				try++
			}
		}
	}

	fmt.Fprintln(out, len(s[bi]))
	for i, c := range res {
		if i+1 == m {
			fmt.Fprintln(out, c)
		} else {
			fmt.Fprint(out, c, " ")
		}
	}
}