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 "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))

    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)
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pk, _ := Readln(reader)
	k, _ := strconv.Atoi(pk)
	for oi := 0; oi < k; oi++ {

		pparam,_ := Readln(reader)
		params := strings.Split(pparam, " ")
		length,_ := strconv.Atoi(params[0])
		a,_ := strconv.Atoi(params[1])
		b,_ := strconv.Atoi(params[2])

		str,_ := Readln(reader)
		//fmt.Println(str)

		if b >= 0 {
			fmt.Println(length*(b+a))
		} else {
			// we minimize number batches we delete
			segs := 1
			prev := str[0]
			i:= 0
			for i<len(str) {
				for str[i] == prev {
					i++
					if i >= len(str) {
						break
					}
				}
				if i >= len(str) {
					break
				}
				prev = str[i]
				segs++

			}
			//fmt.Println(segs)

			batch := (segs/2) +1

			fmt.Println( length * a + batch * b)

		}

	}

}

package main

import (
	"fmt"
)

func maxCost(bin string, n int, a int, b int) int {
		if b >= 0 {
			return n*(a + b)
		}

		count := 0

		for i := 1; i < n; i++ {
			if bin[i] != bin[i - 1] {
				count++
			}
		}

		r := count % 2
		count = count / 2

		if r == 0 {
			count += 1
		} else { // r == 1
			count += 2
		}

		return n * a + count * b
}

func main() {
	t := 0
	fmt.Scanln(&t)

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		a := 0
		b := 0

		fmt.Scan(&n)
		fmt.Scan(&a)
		fmt.Scanln(&b)
		fmt.Scanln(&s)
		r := maxCost(s, n, a, b)
		fmt.Println(r)
	}
}

package main

import (
	"fmt"
)

func findLongestSlice(str string) (count int) {
	count = 1
	for i := 1; i < len(str); i++ {
		if str[i] != str[i-1] {
			count++
		}
	}
	return
}

func getMaxScore(n, a, b int, str string) (score int) {
	if n == 1 {
		return a + b
	}
	score = -2100000000
	minSlice := findLongestSlice(str)
	if minSlice % 2 == 0 {
		minSlice = (findLongestSlice(str) - 2) / 2 + 2
	} else {
		minSlice = (findLongestSlice(str) - 1) / 2 + 1
	}
	maxSlice := n
	for maxSlice >= minSlice {
		if (a * n + maxSlice * b) > score {
			score = a * n + maxSlice * b
		}
		maxSlice--
	}
	return
}

func main() {
	var t, n, a, b int
	var str string
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&n, &a, &b, &str)
		fmt.Println(getMaxScore(n, a, b, str))
	}
}

package main

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

var (
	reader     = bufio.NewReader(os.Stdin)
	t, n, a, b int
	s          string
)

func solve(n, a, b int, s string) int {
	if b >= 0 {
		return (a + b) * n
	}
	f := 1
	for i := range s {
		if i > 0 && s[i] != s[i-1] {
			f++
		}
	}
	return a*n + (f/2+1)*b
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &a, &b)
		fmt.Fscan(reader, &s)
		fmt.Println(solve(n, a, b, s))
	}
}

package main

import (
    "fmt"
)

func main() {
    var testCases int

    fmt.Scanln(&testCases)

    for i := 0; i < testCases; i++ {
        var (
            n int
            a int
            b int
            line string
        )

        fmt.Scanf("%d %d %d\n", &n, &a, &b)
        //scna line
        fmt.Scanln(&line)

        if b == 0 {
            fmt.Printf("%d\n", a*n)
        } else if b < 0 {
            operations := computeOp(line)
            fmt.Printf("%d\n", a*n + operations*b)
        } else {
            fmt.Printf("%d\n", n * (a+b))
        }
    }
}

func computeOp(line string) int {
    arr := []string{}
    back, forw := 0, 1
    for ; forw < len(line); {
        if line[back] != line[forw] {
            arr = append(arr, string(line[back]))
        }
        back++
        forw++
    }
    arr = append(arr, string(line[forw-1]))
    ones, zeros := 0, 0
    for _, v := range arr {
        if v == "1" {
            ones++
        } else {
            zeros++
        }
    }
    if ones < zeros {
        return ones + 1
    }
    return zeros + 1
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)

	var TC int
	fmt.Fscan(r, &TC)

	for tc := 0; tc < TC; tc += 1 {
		var n, a, b int
		var s string
		fmt.Fscan(r, &n, &a, &b, &s)

		if b >= 0 {
			fmt.Printf("%d\n", n * (a + b))
			continue
		}

		first := true
		segments := 1
		var cc rune
		for _, c := range s {
			if first {
				first = false
				cc = c
			}
			if c != cc {
				segments += 1
				cc = c
			}
		}
		fmt.Printf("%d\n", n * a + (segments / 2 + 1) * b)
	}
}

package main

import (
	"fmt"
)

func minOps(s string) int {
	var diff int = 1
	for i := 1; i < len(s); i++ {
		if s[i] != s[i-1] { diff++ }
	}
	return diff / 2 + 1
}

func maxPoints(n, a, b int, s string) int {
	var opsCount int

	if (b >= 0) {
		opsCount = n
	} else {
		opsCount = minOps(s)
	}

	return a * n + b * opsCount
}

func main() {
	var t int

	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		var n, a, b int
		var s string
		fmt.Scan(&n, &a, &b, &s)
		fmt.Println(maxPoints(n, a, b, s))
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var t, a, b int
		fmt.Scan(&t, &a, &b)
		var s string
		fmt.Scan(&s)
		if b > 0 {
			fmt.Println((a + b) * t)
		} else {
			x := 1
			for j := 0; j + 1 < t; j++ {
				if s[j] != s[j+1] {
					x++
				}
			}
			fmt.Println(a*t + b*(x/2+1))
		}
	}
}

package main

import ."fmt"
//import "sort"
import "bufio"
import "os"
//import "math"
//import "string"
//import "time"
//import ."math"

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)
var scanner = bufio.NewScanner(os.Stdin)

func minOps(s string) int64 {
	var diff int64 = int64(1)
	for i := 1; i < len(s); i++ {
		if s[i] != s[i-1] { diff++ }
	}
	return diff / 2 + 1
}

func maxPoints(n, a, b int64, s string) int64 {
	var opsCount int64

	if (b >= 0) {
		opsCount = n
	} else {
		opsCount = minOps(s)
	}

	return a * n + b * opsCount
}

func main() {
    defer writer.Flush()
    t := sint64();
    for i := int64(0); i < t; i++ {
        n := sint64()
        a := sint64()
        b := sint64()
        s := sstring()
        printf("%d\n", maxPoints(n, a, b, s))
    }

}
func resh(n int64) []int64 {
    p := make([]bool, n + 1)
    for i := int64(2); i <= n; i++ {
        p[i] = true
    }
    for i := int64(0); i <= n; i++ {
		if p[i] {
			for j := i * i; j <= n; j += i {
				p[j] = false
				//Print(j, " ")
			}
		}
	}
	ans := make([]int64, 0)
	for i := int64(0); i < n; i++ {
	    if p[i] {
	        ans = append(ans, i)
	    }
	}
	return ans
}
func printf(f string, a ...interface{}) {
	Fprintf(writer, f, a...)
}
func sstring() string {
	scanner.Scan()
	return scanner.Text()
}
func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sum(a []int64) int64{
    ans := int64(0)
    for _, i := range a {
        ans += i
    }
    return ans
}
func abs(x int64) int64 {
    if x < 0 {
        return 0 - x
    }
    return x
}
func min(x, y int64) int64 {
    if x < y {
        return x
    }
    return y
}
func ceil(a, b int64) int64{
    s := a / b
    if a % b >= 0 {
        s++
    }
    if s == 0 {
        s = 1
    }
    return s
}
func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

package main

import "fmt"

func main() {
	// arr := []byte{}
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var t, a, b int
		fmt.Scan(&t, &a, &b)
		var s string
		fmt.Scan(&s)
		if b > 0 {
			fmt.Println((a + b) * t)
		} else {
			x := 1
			for j := 0; j < t-1; j++ {
				if s[j] != s[j+1] {
					x++
				}
			}
			fmt.Println(a*t + b*(x/2+1))
		}
	}
}

package main

import ."fmt"
//import "sort"
import "bufio"
import "os"
//import "math"
//import "string"
//import "time"
//import ."math"

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)
var scanner = bufio.NewScanner(os.Stdin)

func main() {
    defer writer.Flush()
    t := sint64();
    for i := int64(0); i < t; i++ {
        n := sint64()
        a := sint64()
        b := sint64()
        sstring()
        if(n == 1){
            printf("%d\n", a+b)
        } else{
        ans := (a+b)*n
        if(a+b < 0 && (a > 0 || b > 0)){
            ans = -(n / abs(a+b))
        }
        printf("%d\n", ans)
        }
    }

}
func resh(n int64) []int64 {
    p := make([]bool, n + 1)
    for i := int64(2); i <= n; i++ {
        p[i] = true
    }
    for i := int64(0); i <= n; i++ {
		if p[i] {
			for j := i * i; j <= n; j += i {
				p[j] = false
				//Print(j, " ")
			}
		}
	}
	ans := make([]int64, 0)
	for i := int64(0); i < n; i++ {
	    if p[i] {
	        ans = append(ans, i)
	    }
	}
	return ans
}
func printf(f string, a ...interface{}) {
	Fprintf(writer, f, a...)
}
func sstring() string {
	scanner.Scan()
	return scanner.Text()
}
func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sum(a []int64) int64{
    ans := int64(0)
    for _, i := range a {
        ans += i
    }
    return ans
}
func abs(x int64) int64 {
    if x < 0 {
        return 0 - x
    }
    return x
}
func min(x, y int64) int64 {
    if x < y {
        return x
    }
    return y
}
func ceil(a, b int64) int64{
    s := a / b
    if a % b >= 0 {
        s++
    }
    if s == 0 {
        s = 1
    }
    return s
}
func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

package main

import ."fmt"
//import "sort"
import "bufio"
import "os"
//import "math"
//import "string"
//import "time"
//import ."math"

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)
var scanner = bufio.NewScanner(os.Stdin)

func main() {
    defer writer.Flush()
    t := sint64();
    for i := int64(0); i < t; i++ {
        n := sint64()
        a := sint64()
        b := sint64()
        sstring()
        ans := (a+b)*n
        if(a+b < 0 && (a >= 0 || b >= 0)){
            ans = -(n / abs(a+b))
        }
        printf("%d\n", ans)
    }

}
func resh(n int64) []int64 {
    p := make([]bool, n + 1)
    for i := int64(2); i <= n; i++ {
        p[i] = true
    }
    for i := int64(0); i <= n; i++ {
		if p[i] {
			for j := i * i; j <= n; j += i {
				p[j] = false
				//Print(j, " ")
			}
		}
	}
	ans := make([]int64, 0)
	for i := int64(0); i < n; i++ {
	    if p[i] {
	        ans = append(ans, i)
	    }
	}
	return ans
}
func printf(f string, a ...interface{}) {
	Fprintf(writer, f, a...)
}
func sstring() string {
	scanner.Scan()
	return scanner.Text()
}
func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sum(a []int64) int64{
    ans := int64(0)
    for _, i := range a {
        ans += i
    }
    return ans
}
func abs(x int64) int64 {
    if x < 0 {
        return 0 - x
    }
    return x
}
func min(x, y int64) int64 {
    if x < y {
        return x
    }
    return y
}
func ceil(a, b int64) int64{
    s := a / b
    if a % b >= 0 {
        s++
    }
    if s == 0 {
        s = 1
    }
    return s
}
func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

package main

import ."fmt"
//import "sort"
import "bufio"
import "os"
//import "math"
//import "string"
//import "time"
//import ."math"

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)
var scanner = bufio.NewScanner(os.Stdin)

func main() {
    defer writer.Flush()
    t := sint64();
    for i := int64(0); i < t; i++ {
        n := sint64()
        a := sint64()
        b := sint64()
        sstring()
        ans := (a+b)*n
        if(a+b < 0 && (a > 0 || b > 0)){
            ans = -(n / abs(a+b))
        }
        printf("%d\n", ans)
    }

}
func resh(n int64) []int64 {
    p := make([]bool, n + 1)
    for i := int64(2); i <= n; i++ {
        p[i] = true
    }
    for i := int64(0); i <= n; i++ {
		if p[i] {
			for j := i * i; j <= n; j += i {
				p[j] = false
				//Print(j, " ")
			}
		}
	}
	ans := make([]int64, 0)
	for i := int64(0); i < n; i++ {
	    if p[i] {
	        ans = append(ans, i)
	    }
	}
	return ans
}
func printf(f string, a ...interface{}) {
	Fprintf(writer, f, a...)
}
func sstring() string {
	scanner.Scan()
	return scanner.Text()
}
func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sum(a []int64) int64{
    ans := int64(0)
    for _, i := range a {
        ans += i
    }
    return ans
}
func abs(x int64) int64 {
    if x < 0 {
        return 0 - x
    }
    return x
}
func min(x, y int64) int64 {
    if x < y {
        return x
    }
    return y
}
func ceil(a, b int64) int64{
    s := a / b
    if a % b >= 0 {
        s++
    }
    if s == 0 {
        s = 1
    }
    return s
}
func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

package main

import ."fmt"
//import "sort"
import "bufio"
import "os"
//import "math"
//import "string"
//import "time"
//import ."math"

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)
var scanner = bufio.NewScanner(os.Stdin)

func main() {
    defer writer.Flush()
    t := sint64();
    for i := int64(0); i < t; i++ {
        n := sint64()
        a := sint64()
        b := sint64()
        sstring()
        ans := (a+b)*n
        if(a+b < 0){
            ans = -(n / abs(a+b))
        }
        printf("%d\n", ans)
    }

}
func resh(n int64) []int64 {
    p := make([]bool, n + 1)
    for i := int64(2); i <= n; i++ {
        p[i] = true
    }
    for i := int64(0); i <= n; i++ {
		if p[i] {
			for j := i * i; j <= n; j += i {
				p[j] = false
				//Print(j, " ")
			}
		}
	}
	ans := make([]int64, 0)
	for i := int64(0); i < n; i++ {
	    if p[i] {
	        ans = append(ans, i)
	    }
	}
	return ans
}
func printf(f string, a ...interface{}) {
	Fprintf(writer, f, a...)
}
func sstring() string {
	scanner.Scan()
	return scanner.Text()
}
func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sum(a []int64) int64{
    ans := int64(0)
    for _, i := range a {
        ans += i
    }
    return ans
}
func abs(x int64) int64 {
    if x < 0 {
        return 0 - x
    }
    return x
}
func min(x, y int64) int64 {
    if x < y {
        return x
    }
    return y
}
func ceil(a, b int64) int64{
    s := a / b
    if a % b >= 0 {
        s++
    }
    if s == 0 {
        s = 1
    }
    return s
}
func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pk, _ := Readln(reader)
	k, _ := strconv.Atoi(pk)
	for oi := 0; oi < k; oi++ {

		pparam,_ := Readln(reader)
		params := strings.Split(pparam, " ")
		length,_ := strconv.Atoi(params[0])
		a,_ := strconv.Atoi(params[1])
		b,_ := strconv.Atoi(params[2])

		str,_ := Readln(reader)
		//fmt.Println(str)

		if b >= 0 {
			fmt.Println(length*(b+a))
		} else {
			// we minimize number batches we delete
			segs := 1
			prev := str[0]
			i:= 0
			for i<len(str) {
				for str[i] == prev {
					i++
					if i >= len(str) {
						break
					}
				}
				if i >= len(str) {
					break
				}
				prev = str[i]
				segs++

			}
			fmt.Println(segs)

			batch := (segs/2) +1

			fmt.Println( length * a + batch * b)

		}

	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pk, _ := Readln(reader)
	k, _ := strconv.Atoi(pk)
	for oi := 0; oi < k; oi++ {

		pparam,_ := Readln(reader)
		params := strings.Split(pparam, " ")
		length,_ := strconv.Atoi(params[0])
		a,_ := strconv.Atoi(params[1])
		b,_ := strconv.Atoi(params[2])

		str,_ := Readln(reader)
		//fmt.Println(str)

		if b >= a {
			fmt.Println(length*(b+a))
		} else {

			count0 := 0
			count1 := 0
			for i := range str {
				if str[i] == '1' {
					count1++
				} else {
					count0++
				}
			}

			score :=0
			if count0 <= count1 {
				cur0run := 0
				for i:= 0; i<len(str); i++ {

					if str[i] == '1' {

						if cur0run != 0 {
							score+= (a*cur0run)+b

						}
						cur0run =0
						continue
					}
					cur0run++
				}
				if cur0run !=0 {
					score+= (a*cur0run)+b
				}
				if count1 !=0 {
					score+= (a*count1)+b
				}
				fmt.Println(score)

			} else {
				cur1run := 0
				for i:= 0; i<len(str); i++ {
					if str[i] == '0' {
						if cur1run != 0 {
							score+= (a*cur1run)+b
						}
						cur1run =0
						continue
					}
					cur1run++
				}
				if cur1run !=0 {
					score+= (a*cur1run)+b
				}
				if count0 != 0{
					score+= (a*count0)+b
				}
				fmt.Println(score)
			}

		}

	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pk, _ := Readln(reader)
	k, _ := strconv.Atoi(pk)
	for oi := 0; oi < k; oi++ {

		pparam,_ := Readln(reader)
		params := strings.Split(pparam, " ")
		length,_ := strconv.Atoi(params[0])
		a,_ := strconv.Atoi(params[1])
		b,_ := strconv.Atoi(params[2])

		str,_ := Readln(reader)
		//fmt.Println(str)

		if b >= a {
			fmt.Println(length*(b+a))
		} else {

			count0 := 0
			count1 := 0
			for i := range str {
				if str[i] == '1' {
					count1++
				} else {
					count0++
				}
			}

			score :=0
			if count0 <= count1 {
				cur0run := 0
				for i:= 0; i<len(str); i++ {
					if str[i] == '1' {

						if cur0run != 0 {
							score+= (a*cur0run)+b
						}
						cur0run =0
						continue
					}
					cur0run++
				}
				score+= (a*cur0run)+b
				score+= (a*count1)+b
				fmt.Println(score)
			} else {
				cur1run := 0
				for i:= 0; i<len(str); i++ {
					if str[i] == '0' {
						if cur1run != 0 {
							score+= (a*cur1run)+b
						}
						cur1run =0
						continue
					}
					cur1run++
				}
				score+= (a*cur1run)+b
				score+= (a*count0)+b
				fmt.Println(score)
			}

		}

	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	pk, _ := Readln(reader)
	k, _ := strconv.Atoi(pk)
	for oi := 0; oi < k; oi++ {

		pparam,_ := Readln(reader)
		params := strings.Split(pparam, " ")
		length,_ := strconv.Atoi(params[0])
		a,_ := strconv.Atoi(params[1])
		b,_ := strconv.Atoi(params[2])

		str,_ := Readln(reader)
		fmt.Println(str)

		if b >= a {
			fmt.Println(length*(b+a))
		} else {

			count0 := 0
			count1 := 0
			for i := range str {
				if str[i] == '1' {
					count1++
				} else {
					count0++
				}
			}

			score :=0
			if count0 <= count1 {
				cur0run := 0
				for i:= 0; i<len(str); i++ {
					if str[i] == '1' {

						if cur0run != 0 {
							score+= (a*cur0run)+b
						}
						cur0run =0
						continue
					}
					cur0run++
				}
				score+= (a*cur0run)+b
				score+= (a*count1)+b
				fmt.Println(score)
			} else {
				cur1run := 0
				for i:= 0; i<len(str); i++ {
					if str[i] == '0' {
						if cur1run != 0 {
							score+= (a*cur1run)+b
						}
						cur1run =0
						continue
					}
					cur1run++
				}
				score+= (a*cur1run)+b
				score+= (a*count0)+b
				fmt.Println(score)
			}

		}

	}

}

package main

import "fmt"

func main() {
	// arr := []byte{}
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var t, a, b int
		fmt.Scan(&t, &a, &b)
		var s string
		fmt.Scan(&s)
		if b > 0 {
			fmt.Println((a + b) * t)
			break
		} else {
			x := 1
			for j := 0; j < t-1; j++ {
				if s[j] != s[j+1] {
					x++
				}
			}
			fmt.Println(a*t + b*(x/2+1))
		}
	}
}

package main

import "fmt"

func main() {
	arr := []byte{}
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var t, a, b int
		fmt.Scan(&t, &a, &b)
		for i := 0; i < t; i++ {
			var c byte
			fmt.Scan(&c)
			arr = append(arr, c)
		}
		if b >= 0 {
			fmt.Println((a + b) * t)
			break
		} else {
			x := 1
			for j := 0; j < t; j++ {
				if arr[j] != arr[j+1] {
					x++
				}
			}
			fmt.Println(a*t + b*(x/2+1))
		}
	}
}

package main

import "fmt"

func main() {
	arr := []byte{}
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var t, a, b int
		fmt.Scan(&t, &a, &b)
		for i := 0; i < t; i++ {
			var c byte
			fmt.Scan(&c)
			arr = append(arr, c)
		}
		if b >= 0 {
			fmt.Println((a + b) * t)
		} else {
			x := 1
			for j := 0; j < t; j++ {
				if arr[j] != arr[j+1] {
					x++
				}
			}
			fmt.Println(a*t + b*(x/2+1))
		}
	}
}

package main

import (
	"fmt"
)

func maxCost(bin string, n int, a int, b int) int {
		if b >= 0 {
			return n*(a + b)
		}

		count := 0

		for i := 1; i < n; i++ {
			if bin[i] != bin[i - 1] {
				count++
			}
		}

		if count < 2 {
			count++
		}

		return n * a + count * b
}

func main() {
	t := 0
	fmt.Scanln(&t)

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		a := 0
		b := 0

		fmt.Scan(&n)
		fmt.Scan(&a)
		fmt.Scanln(&b)
		fmt.Scanln(&s)
		r := maxCost(s, n, a, b)
		fmt.Println(r)
	}
}

package main

import (
	"fmt"
)

func maxCost(bin string, n int, a int, b int) int {
		if b >= 0 {
			return n*(a + b)
		}

		count := 0

		for i := 1; i < n - 1; i++ {
			if bin[i] != bin[i - 1] {
				count++
			}
		}

		if count < 2 {
			count++
		}

		return n * a + count * b
}

func main() {
	t := 0
	fmt.Scanln(&t)

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		a := 0
		b := 0

		fmt.Scan(&n)
		fmt.Scan(&a)
		fmt.Scanln(&b)
		fmt.Scanln(&s)
		r := maxCost(s, n, a, b)
		fmt.Println(r)
	}
}

package main

import (
	"fmt"
)

// type Visited struct{
// 	value int64
// 	from int
// 	to int
// }

// var binToDec = binToDecFactory()

// func binToDecFactory() func(string)int64 {
// 	cache := map[string]int64{}

// 	return func(bin string) int64 {
// 		if v, ok := cache[bin]; ok {
// 			return v
// 		}

// 		// do the math
// 		r := int64(0)
// 		l := len(bin)

// 		t := int64(1)
// 		for i := l - 1; i >= 0; i-- {
// 			if bin[i] == '1' {
// 				r += t
// 			}

// 			t *= 2
// 		}

// 		cache[bin] = r
// 		return r
// 	}
// }

// func findPairs(bin string, n int) [4]int {
// 	var r [4]int
// 	var visited []Visited

// 	m := int(n / 2)

// 	for i := 0; i <= m; i++ {
// 		for j := i + m - 1; j < n; j++ {
// 			dec := binToDec(bin[i:j+1])

// 			for _, v := range visited {
// 				if v.value != 0 && dec % v.value == 0 {
// 					return [4]int{i + 1, j + 1, v.from, v.to}
// 				}

// 				if dec != 0 && v.value % dec == 0 {
// 					return [4]int{v.from, v.to, i + 1, j + 1}
// 				}
// 			}

// 			visited = append(visited, Visited{dec, i + 1, j + 1})
// 		}
// 	}

// 	return r
// }

func maxCost(bin string, n int, a int, b int) int {
		if b >= 0 {
			return n*(a + b)
		}

		count := 0

		for i := 1; i < n - 1; i++ {
			if bin[i] != bin[i - 1] {
				count++
			}
		}

		return n * a + count * b
}

func main() {
	t := 0
	fmt.Scanln(&t)

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		a := 0
		b := 0

		fmt.Scan(&n)
		fmt.Scan(&a)
		fmt.Scanln(&b)
		fmt.Scanln(&s)
		r := maxCost(s, n, a, b)
		fmt.Println(r)
	}
}

package main

import (
	"fmt"
)

func findLongestSlice(str string) (count int) {
	count = 1
	for i := 1; i < len(str); i++ {
		if str[i] != str[i-1] {
			count++
		}
	}
	return
}

func getMaxScore(n, a, b int, str string) (score int) {
	score = -10000
	minSlice := findLongestSlice(str)
	if minSlice % 2 == 0 {
		minSlice = (findLongestSlice(str) - 2) / 2 + 2
	} else {
		minSlice = (findLongestSlice(str) - 1) / 2 + 1
	}
	maxSlice := n
	for maxSlice >= minSlice {
		if (a * n + maxSlice * b) > score {
			score = a * n + maxSlice * b
		}
		maxSlice--
	}
	return
}

func main() {
	var t, n, a, b int
	var str string
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&n, &a, &b, &str)
		fmt.Println(getMaxScore(n, a, b, str))
	}
}

package main

import (
	"fmt"
)

func findLongestSlice(str string) (count int) {
	count = 1
	for i := 1; i < len(str); i++ {
		if str[i] != str[i-1] {
			count++
		}
	}
	return
}

func getMaxScore(n, a, b int, str string) (score int) {
	score = -10000
	minSlice := (findLongestSlice(str) - 1) / 2 + 1
	maxSlice := n
	for maxSlice >= minSlice {
		if (a * n + maxSlice * b) > score {
			score = a * n + maxSlice * b
		}
		maxSlice--
	}
	return
}

func main() {
	var t, n, a, b int
	var str string
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&n, &a, &b, &str)
		fmt.Println(getMaxScore(n, a, b, str))
	}
}

package main

import (
	"fmt"
)

func getMaxScore(n, a, b int, str string) (score int) {
	score = -10000
	slice := n
	for slice > 0 {
		if (a * n + slice * b) > score {
			score = a * n + slice * b
		}
		slice--
	}
	return
}

func main() {
	var t, n, a, b int
	var str string
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&n, &a, &b, &str)
		fmt.Println(getMaxScore(n, a, b, str))
	}
}

package main

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

var (
	reader     = bufio.NewReader(os.Stdin)
	t, n, a, b int
	s          string
)

func solve(n, a, b int, s string) int {
	if b >= 0 {
		return (a + b) * n
	}
	f := 1
	for i := range s {
		if i > 0 && s[i] != s[i-1] {
			f++
		}
	}
	return a*n + f*b
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &a, &b)
		fmt.Fscan(reader, &s)
		fmt.Println(solve(n, a, b, s))
	}
}

package main

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

var (
	reader     = bufio.NewReader(os.Stdin)
	t, n, a, b int
	s          string
)

func solve(n, a, b int, s string) int {
	if b >= 0 {
		return (a + b) * n
	}
	f := 0
	for i := range s {
		if i > 0 && s[i] != s[i-1] {
			f++
		}
	}
	return a*n + f*b
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &a, &b)
		fmt.Fscan(reader, &s)
		fmt.Println(solve(n, a, b, s))
	}
}

package main

import (
    "fmt"
)

func main() {
    var testCases int

    fmt.Scanln(&testCases)

    for i := 0; i < testCases; i++ {
        var (
            n int
            a int
            b int
            line string
        )

        fmt.Scanf("%d %d %d\n", &n, &a, &b)
        //scna line
        fmt.Scanln(&line)
        if a == 0 {
            fmt.Printf("%d\n", b)
        } else if a < 0 {
            fmt.Printf("%d\n", n * (a+b))
        } else {
            if b > 0 {
                fmt.Printf("%d\n", n * (a+b))
            } else if b == 0 {
                fmt.Printf("%d\n", a*n)
            } else {
                operations := computeOp(line)
                fmt.Printf("%d\n", a*n + operations*b)
            }
        }
    }
}

func computeOp(line string) int {
    arr := []string{}
    back, forw := 0, 1
    for ; forw < len(line); {
        if line[back] != line[forw] {
            arr = append(arr, string(line[back]))
        }
        back++
        forw++
    }
    arr = append(arr, string(line[forw-1]))
    ones, zeros := 0, 0
    for _, v := range arr {
        if v == "1" {
            ones++
        } else {
            zeros++
        }
    }
    if ones < zeros {
        return ones + 1
    }
    return zeros + 1
}

package main

import (
    "fmt"
)

func main() {
    var testCases int

    fmt.Scan(&testCases)

    for i := 0; i < testCases; i++ {
        var (
            n int
            a int
            b int
            line string
        )

        fmt.Scanf("%d %d %d", &n, &a, &b)
        //scna line
        fmt.Scan(&line)
        if a == 0 {
            fmt.Println(b)
        } else if a < 0 {
            fmt.Println(n * (a+b))
        } else {
            if b > 0 {
                fmt.Println(n * (a+b))
            } else if b == 0 {
                fmt.Println(a*n)
            } else {
                operations := computeOp(line)
                fmt.Println(a*n + operations*b)
            }
        }
    }
}

func computeOp(line string) int {
    arr := []string{}
    back, forw := 0, 1
    for ; forw < len(line); {
        if line[back] != line[forw] {
            arr = append(arr, string(line[back]))
        }
        back++
        forw++
    }
    arr = append(arr, string(line[forw-1]))
    ones, zeros := 0, 0
    for _, v := range arr {
        if v == "1" {
            ones++
        } else {
            zeros++
        }
    }
    if ones < zeros {
        return ones + 1
    }
    return zeros + 1
}