package main

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

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

type Spell struct {
	time int
	mana int
}

type SpellSlice []Spell

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

func min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

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

	var n, m, k int
	var x, s int

	fmt.Fscanf(bufin, "%d %d %d\n", &n, &m, &k)
	fmt.Fscanf(bufin, "%d %d\n", &x, &s)

	spells := make(SpellSlice, m+1)
	spells[0] = Spell{time: x, mana: 0}

	for i := 1; i <= m; i++ {
		fmt.Fscanf(bufin, "%d\n", &spells[i].time)
	}
	for i := 1; i <= m; i++ {
		fmt.Fscanf(bufin, "%d\n", &spells[i].mana)
	}

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

	sort.Sort(spells)
	res := int64(x) * int64(n)

	j := k - 1
	for i := 0; i <= m; i++ {
		if spells[i].mana <= s {
			remainMana := s - spells[i].mana
			remainPotion := n
			remainTime := spells[i].time
			for (j >= 0) && (d[j] > remainMana) {
				j--
			}
			if j >= 0 {
				remainPotion -= c[j]
			}
			total := int64(remainPotion) * int64(remainTime)
			if total < res {
				res = total
			}
		}
	}

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

// Codeforces 734 C AntonMakingPotions,
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"strconv"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for j:=0; j<n; j++ {
		aa,err := strconv.Atoi(ss[j])
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[j] = aa
	}
	return a
}

var n,m,k int
var x,s int
var a []int
var b []int
var c []int
var d []int

var minTime int64

func readData() {
	in = bufio.NewReader(os.Stdin)
	// reading field
	n,m,k,_,_ = readFive()
	x,s,_,_,_ = readFive()
	a = readLineNumbs(m)
	b = readLineNumbs(m)
	c = readLineNumbs(k)
	d = readLineNumbs(k)
}

func binFindMaxLessd(lman int) int {
	if lman<d[0] {
		return -1
	}
	i0 := 0
	i1 := k
	for i1 > i0 {
		ii := (i0 + i1)/2
		//fmt.Printf("ii,i0,i1 = %d %d %d d[ii],lman = %d %d\n",ii,i0,i1,d[ii],lman)
		if ii==i0 {
			break
		} else if d[ii] <= lman {
			i0 = ii
		} else {
			i1 = ii
		}
	}
	//fmt.Printf("binFindMaxLessd(), lman i0 = %d %d\n", lman, i0)
	return i0
}

func solve() {
	minTime = int64(n)*int64(x)
	a = append(a, int(x))
	b = append(b, 0)
	for i:=0; i<m+1; i++ {
		if b[i] <= s {
			o := s-b[i]
			nskip := 0
			didx := binFindMaxLessd(o)
			if didx>=0 {
				nskip = c[didx]
			}
			ctime := int64(a[i]) * int64(n-nskip)
			if ctime < minTime {
				minTime = ctime
			}
		}
	}
}

func printRes() {
	fmt.Println(minTime)
}

func main() {
	readData()
	solve()
	printRes()
}

package main

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

const MAX_MK = 200010

var N int64
var M, K int
var X, S int64
var A [MAX_MK]int64
var B [MAX_MK]int64
var C [MAX_MK]int64
var D [MAX_MK]int64

func lowerBound(mana int64) int64 {
	var left, right int
	left = -10
	right = K + 10
	var result int64
	result = 0
	for right-left > 1 {
		med := (right + left) / 2
		//fmt.Println("med", med)
		if med < 0 {
			left = med
			continue
		}
		if med > K-1 {
			right = med
			continue
		}
		reqMana := D[med]
		if reqMana > mana {
			right = med
		} else {
			left = med
			result = C[med]
		}
	}
	return result
}

func solve() {
	var result int64
	result = 1 << 62
	for i := 0; i < int(M+1); i++ {
		var pre, mana int64
		if i < int(M) && B[i] <= S {
			pre = A[i]
			mana = S - B[i]
		} else {
			pre = X
			mana = S
		}
		var needPotions int64
		needPotions = N
		needPotions -= lowerBound(mana)
		if needPotions <= 0 {
			result = 0
			break
		}

		if needPotions*pre < result {
			result = needPotions * pre
		}
		//fmt.Println(i, needPotions, pre)
		//fmt.Println(i, needPotions*pre)
	}
	fmt.Println(result)
}

func main() {
	fsc := NewFastScanner()
	N, M, K = fsc.NextInt64(), fsc.NextInt(), fsc.NextInt()
	X, S = fsc.NextInt64(), fsc.NextInt64()
	for i := 0; i < M; i++ {
		A[i] = fsc.NextInt64()
	}
	for i := 0; i < M; i++ {
		B[i] = fsc.NextInt64()
	}

	for i := 0; i < K; i++ {
		C[i] = fsc.NextInt64()
	}
	for i := 0; i < K; i++ {
		D[i] = fsc.NextInt64()
	}
	solve()
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 2028)
	return &FastScanner{r: rdr}
}

func (s *FastScanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *FastScanner) NextInt() int {
	val, err := strconv.Atoi(s.Next())
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) NextInt64() int64 {
	val, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}

func (s *FastScanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, err := s.r.ReadLine()
		if err != nil {
			panic(err.Error())
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int64
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n int64) {
	var m, k, x, s int64
	I(&m, " ")
	I(&k, "\n")
	I(&x, " ")
	I(&s, "\n")
	mm := make([][2]int64, m)
	kk := make([][2]int64, k)
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][0], o)
	}
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][1], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][0], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][1], o)
	}
	min := n * x
	for i := int64(0); i < m; i++ {
		xx := x
		ss := s
		if s >= mm[i][1] {
			xx = mm[i][0]
			ss -= mm[i][1]
		} else {
			continue
		}
		nn := n
		vv := int(k)
		vvv := sort.Search(vv, func(v int) bool { return kk[v][1] > ss })
		if vvv != 0 {
			nn -= kk[vvv-1][0]
		}
		if min > xx*nn {
			min = xx * nn
		}
	}
	for i := int64(0); i < m; i++ {
		xx := x
		ss := s
		nn := n
		vv := int(k)
		vvv := sort.Search(vv, func(v int) bool { return kk[v][1] > ss })
		if vvv != 0 {
			nn -= kk[vvv-1][0]
			ss -= kk[vvv-1][1]
		}
		if ss >= mm[i][1] {
			xx = mm[i][0]
			ss -= mm[i][1]
		}
		if min > xx*nn {
			min = xx * nn
		}
	}
	O(min, "\n")
}

package main

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

func solve() {
    n, m, k, x, s := readInt(), readInt(), readInt(), readInt(), readInt()
    a, b := readIntArray(m), readIntArray(m)
    c, d := readIntArray(k), readIntArray(k)

    cc, dd := []int{}, []int{}
    for i := 0; i < k; i++ {
        if i == k-1 || d[i] < d[i+1] {
            cc = append(cc, c[i])
            dd = append(dd, d[i])
        }
    }
    c, d, k = cc, dd, len(cc)

    findC := func(mana int) int {
        l, r := 0, k-1
        if d[l] > mana {
            return 0
        }

        for l < r {
            mid := (l+r+1) / 2
            if d[mid] > mana {
                r = mid - 1
            } else {
                l = mid
            }
        }

        return c[l]
    }

    ans := int64(n) * int64(x)
    for i := 0; i <= m; i++ {
        mana, speed := s, x
        if i < m && mana >= b[i] {
            mana -= b[i]
            speed = a[i]
        }
        cnt := int64(max(n - findC(mana), 0))
        curAns := cnt * int64(speed)
        if curAns < ans {
            ans = curAns
        }
    }
    fmt.Println(ans)
}

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

package main

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

// MAX32 is
var MAX32 int32 = 2147483647

// MIN32 is
var MIN32 int32 = -2147483648

// MAX64 is
var MAX64 int64 = 9223372036854775807

// MIN64 is
var MIN64 int64 = -9223372036854775808

var scanner = bufio.NewScanner(os.Stdin)

var o = bufio.NewWriter(os.Stdout)

func init() {
	// scanner.Buffer()
	scanner.Split(bufio.ScanWords)
}
func end() {
	o.Flush()
}

var n int64
var m int32
var k int32
var x int64
var s int64
var ai []int64
var bi []int64
var ci []int64
var di []int64

func main() {
	defer end()
	n = ri64()             //task
	m = ri32()             // type 1 num
	k = ri32()             // type 2 num
	x = ri64()             // time
	s = ri64()             // mp
	ai = ri64sli(int64(m)) // type 1 xiaoguo
	bi = ri64sli(int64(m)) // type 1 mp
	ci = ri64sli(int64(k)) // type 2 xiaoguo
	di = ri64sli(int64(k)) //type 2 mp
	var last = MAX64
	for idx := int32(1); idx != m+2; idx++ {
		var mpleft int64
		var singletime int64
		if idx == m+1 || s < bi[idx] {
			mpleft = s
			singletime = x
		} else {
			mpleft = s - bi[idx]
			singletime = ai[idx]
		}
		in := bsi64(di, mpleft)
		lefttask := n - ci[in]
		wholetime := int64(singletime) * int64(lefttask)
		if wholetime < last {
			last = wholetime
		}
	}
	oi(last)
	// if n == 1997320486 {
	// 	ostring(" ")
	// 	oi(int64(lastidx))
	// 	ostring(" ")
	// 	oi(lastin)
	// }
	ostring("\n")
}

// IO
func ri32() int32 {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	n32 := int32(n)
	return n32
}
func ri32sli(nums int32) []int32 {
	re := make([]int32, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		re[idx] = ri32()
	}
	return re
}
func ri64() int64 {
	scanner.Scan()
	n64, _ := strconv.ParseInt(scanner.Text(), 0, 64)
	return n64
}
func ri64sli(nums int64) []int64 {
	re := make([]int64, nums+1, nums+1)
	for idx := int64(1); idx != nums+1; idx++ {
		re[idx] = ri64()
	}
	return re
}

func oi(i int64) {
	o.WriteString(fmt.Sprintf("%d", i))
}
func ostring(s string) {
	o.WriteString(s)
}

// math
func bsi64(s []int64, k int64) int64 {
	i := int64(0)
	j := int64(len(s) - 1)
	for i < j {
		m := (i + j + 1) / 2
		if s[m] <= k {
			i = m
		} else {
			j = m - 1
		}
	}
	return i
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int64
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n int64) {
	var m, k, x, s int64
	I(&m, " ")
	I(&k, "\n")
	I(&x, " ")
	I(&s, "\n")
	mm := make([][2]int64, m)
	kk := make([][2]int64, k)
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][0], o)
	}
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][1], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][0], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][1], o)
	}
	min := n * x
	for i := int64(0); i < m; i++ {
		xx := x
		ss := s
		if s >= mm[i][1] {
			xx = mm[i][0]
			ss -= mm[i][1]
		} else {
			continue
		}
		nn := n
		vv := int(k)
		vvv := sort.Search(vv, func(v int) bool { return kk[v][1] > ss })
		if vvv != 0 {
			nn -= kk[vvv-1][0]
		}
		if min > xx*nn {
			min = xx * nn
		}
	}
	O(min, "\n")
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int64
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n int64) {
	var m, k, x, s int64
	I(&m, " ")
	I(&k, "\n")
	I(&x, " ")
	I(&s, "\n")
	mm := make([][2]int64, m)
	kk := make([][2]int64, k)
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][0], o)
	}
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][1], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][0], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][1], o)
	}
	min := n * x
	for i := int64(0); i < m; i++ {
		xx := x
		ss := s
		nn := n
		vv := int(k)
		vvv := sort.Search(vv, func(v int) bool { return kk[v][1] > ss })
		if vvv != 0 {
			nn -= kk[vvv-1][0]
		}
		if s >= mm[i][1] {
			xx = mm[i][0]
			ss -= mm[i][1]
		}
		if min > xx*nn {
			min = xx * nn
		}
	}
	O(min, "\n")
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n uint64
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n uint64) {
	var m, k, x, s uint64
	I(&m, " ")
	I(&k, "\n")
	I(&x, " ")
	I(&s, "\n")
	mm := make([][2]uint64, m)
	kk := make([][2]uint64, k)
	for i := uint64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][0], o)
	}
	for i := uint64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][1], o)
	}
	for i := uint64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][0], o)
	}
	for i := uint64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][1], o)
	}
	min := n * x
	for i := uint64(0); i < m; i++ {
		xx := x
		ss := s
		if s >= mm[i][1] {
			xx = mm[i][0]
			ss = s - mm[i][1]
		}
		nn := n - gg(ss, k, kk)
		if min > xx*nn {
			min = xx * nn
		}
	}
	O(min, "\n")
}

func gg(s, k uint64, kk [][2]uint64) uint64 {
	if s < kk[0][1] {
		return 0
	} else if s >= kk[k-1][1] {
		return kk[k-1][0]
	}
	o := uint64(0)
	oo := k
	for oo != o {
		ooo := (oo + o + 1) / 2
		if s >= kk[ooo][1] {
			o = ooo
		} else {
			oo = ooo - 1
		}
	}
	return kk[o][0]
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n uint64
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n uint64) {
	var m, k, x, s uint64
	I(&m, " ")
	I(&k, "\n")
	I(&x, " ")
	I(&s, "\n")
	mm := make([][2]uint64, m)
	kk := make([][2]uint64, k)
	for i := uint64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][0], o)
	}
	for i := uint64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][1], o)
	}
	for i := uint64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][0], o)
	}
	for i := uint64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][1], o)
	}
	min := n * x
	for i := uint64(0); i < m; i++ {
		xx := x
		ss := s
		if s >= mm[i][1] {
			xx = mm[i][0]
			ss = s - mm[i][1]
		}
		nn := n - gg(ss, k, kk)
		if min > xx*nn {
			min = xx * nn
		}
	}
	O(min, "\n")
}

func gg(s, k uint64, kk [][2]uint64) uint64 {
	if s < kk[0][1] {
		return 0
	} else if s >= kk[k-1][1] {
		return kk[k-1][0]
	}
	o := uint64(0)
	oo := k
	for oo > o && s != kk[o][1] {
		ooo := (oo + o + 1) / 2
		if s > kk[ooo][1] {
			o = ooo
		} else {
			oo = ooo - 1
		}
	}
	return kk[o][0]
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n uint64
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n uint64) {
	var m, k, x, s uint64
	I(&m, " ")
	I(&k, "\n")
	I(&x, " ")
	I(&s, "\n")
	mm := make([][2]uint64, m)
	kk := make([][2]uint64, k)
	for i := uint64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][0], o)
	}
	for i := uint64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][1], o)
	}
	for i := uint64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][0], o)
	}
	for i := uint64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][1], o)
	}
	min := n * x
	for i := uint64(0); i < m; i++ {
		xx := x
		ss := s
		if s >= mm[i][1] {
			xx = mm[i][0]
			ss = s - mm[i][1]
		}
		nn := n - gg(ss, k, kk)
		if min > xx*nn {
			min = xx * nn
		}
	}
	O(min, "\n")
}

func gg(s, k uint64, kk [][2]uint64) uint64 {
	if s < kk[0][1] {
		return 0
	} else if s >= kk[k-1][1] {
		return kk[k-1][0]
	}
	o := uint64(0)
	oo := k
	for {
		ooo := (oo + o) / 2
		if oo == o || s == kk[o][1] {
			return kk[o][0]
		} else if s < kk[o][1] {
			o = ooo
		} else {
			oo = ooo
		}
	}
	return 0
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int64
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n int64) {
	var m, k, x, s int64
	I(&m, " ")
	I(&k, "\n")
	I(&x, " ")
	I(&s, "\n")
	mm := make([][2]int64, m)
	kk := make([][2]int64, k)
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][0], o)
	}
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][1], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][0], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][1], o)
	}
	min := n * x
	for i := int64(0); i < m; i++ {
		xx := x
		ss := s
		pp, ppp := gg(ss, k, kk)
		ss -= ppp
		nn := n - pp
		if ss >= mm[i][1] {
			xx = mm[i][0]
			ss -= mm[i][1]
		}
		if min > xx*nn {
			min = xx * nn
		}

	}
	O(min, "\n")
}

func gg(s, k int64, kk [][2]int64) (int64, int64) {
	if s < kk[0][1] {
		return 0, 0
	} else if s >= kk[k-1][1] {
		return kk[k-1][0], kk[k-1][1]
	}
	o := int64(0)
	oo := k
	for oo != o {
		ooo := (oo + o + 1) / 2
		if s > kk[ooo][1] {
			o = ooo
		} else {
			oo = ooo - 1
		}
	}
	return kk[o][0], kk[o][1]
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int64
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n int64) {
	var m, k, x, s int64
	I(&m, " ")
	I(&k, "\n")
	I(&x, " ")
	I(&s, "\n")
	mm := make([][2]int64, m)
	kk := make([][2]int64, k)
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][0], o)
	}
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][1], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][0], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][1], o)
	}
	min := n * x
	for i := int64(0); i < m; i++ {
		xx := x
		ss := s
		if s >= mm[i][1] {
			xx = mm[i][0]
			ss -= mm[i][1]
		}
		nn := n
		vv := int(k)
		vvv := sort.Search(vv, func(v int) bool { return kk[v][1] > ss })
		if vvv != 0 {
			nn -= kk[vvv-1][0]
		}
		if min > xx*nn {
			min = xx * nn
		}
	}
	O(min, "\n")
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int64
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n int64) {
	var m, k, x, s int64
	I(&m, " ")
	I(&k, "\n")
	I(&x, " ")
	I(&s, "\n")
	mm := make([][2]int64, m)
	kk := make([][2]int64, k)
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][0], o)
	}
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][1], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][0], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][1], o)
	}
	min := n * x
	for i := int64(0); i < m; i++ {
		xx := x
		ss := s
		nn := n
		vv := int(k)
		vvv := sort.Search(vv, func(v int) bool { return kk[v][1] > ss })
		if vvv != 0 {
			nn -= kk[vvv-1][0]
			ss -= kk[vvv-1][1]
		}
		if ss >= mm[i][1] {
			xx = mm[i][0]
			ss -= mm[i][1]
		}
		if min > xx*nn {
			min = xx * nn
		}
	}
	O(min, "\n")
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int64
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n int64) {
	var m, k, x, s int64
	I(&m, " ")
	I(&k, "\n")
	I(&x, " ")
	I(&s, "\n")
	mm := make([][2]int64, m)
	kk := make([][2]int64, k)
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][0], o)
	}
	for i := int64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][1], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][0], o)
	}
	for i := int64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][1], o)
	}
	min := n * x
	for i := int64(0); i < m; i++ {
		xx := x
		ss := s
		if s >= mm[i][1] {
			xx = mm[i][0]
			ss -= mm[i][1]
		}
		nn := n
		qq := gg(ss, k, kk)
		if qq > 0 {
			nn -= qq
		}
		if min > xx*nn {
			min = xx * nn
		}
	}
	O(min, "\n")
}

func gg(s, k int64, kk [][2]int64) int64 {
	if s < kk[0][1] {
		return 0
	} else if s >= kk[k-1][1] {
		return kk[k-1][0]
	}
	o := int64(0)
	oo := k
	for oo > o && s != kk[o][1] {
		ooo := (oo + o + 1) / 2
		if s > kk[ooo][1] {
			o = ooo
		} else {
			oo = ooo - 1
		}
	}
	return kk[o][0]
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n uint64
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n uint64) {
	var m, k, x, s uint64
	I(&m, " ")
	I(&k, "\n")
	I(&x, " ")
	I(&s, "\n")
	mm := make([][2]uint64, m)
	kk := make([][2]uint64, k)
	for i := uint64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][0], o)
	}
	for i := uint64(0); i < m; i++ {
		o := " "
		if i == m-1 {
			o = "\n"
		}
		I(&mm[i][1], o)
	}
	for i := uint64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][0], o)
	}
	for i := uint64(0); i < k; i++ {
		o := " "
		if i == k-1 {
			o = "\n"
		}
		I(&kk[i][1], o)
	}
	min := n * x
	for i := uint64(0); i < m; i++ {
		xx := x
		ss := s
		if s >= mm[i][1] {
			xx = mm[i][0]
			ss = s - mm[i][1]
		}
		nn := n - gg(ss, k, kk)
		if min > xx*nn {
			min = xx * nn
		}
	}
	O(min, "\n")
}

func gg(s, k uint64, kk [][2]uint64) uint64 {
	if s < kk[0][1] {
		return 0
	} else if s >= kk[k-1][1] {
		return kk[k-1][0]
	}
	o := uint64(0)
	oo := k
	for oo != o && s != kk[o][1] {
		ooo := (oo + o + 1) / 2
		if s > kk[ooo][1] {
			o = ooo
		} else {
			oo = ooo - 1
		}
	}
	return kk[o][0]
}

package main

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

func solve() {
    n, m, k, x, s := readInt(), readInt(), readInt(), readInt(), readInt()
    a, b := readIntArray(m), readIntArray(m)
    c, d := readIntArray(k), readIntArray(k)

    findC := func(mana int) int {
        l, r := 0, k-1
        if d[l] > mana {
            return 0
        }

        for l < r {
            mid := (l+r+1) / 2
            if d[mid] > mana {
                r = mid - 1
            } else {
                l = mid
            }
        }

        return c[l]
    }

    ans := n * s
    for i := 0; i <= m; i++ {
        mana, speed := s, x
        if i < m {
            mana -= b[i]
            speed = a[i]
        }
        cnt := n - findC(mana)
        ans = min(ans, cnt * speed)
    }
    fmt.Println(ans)
}

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

package main

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

func solve() {
    n, m, k, x, s := readInt(), readInt(), readInt(), readInt(), readInt()
    a, b := readIntArray(m), readIntArray(m)
    c, d := readIntArray(k), readIntArray(k)
    cc, dd := []int{}, []int{}
    for i := 0; i < k; i++ {
        if i == k-1 || d[i] < d[i+1] {
            cc = append(cc, c[i])
            dd = append(dd, d[i])
        }
    }
    c, d, k = cc, dd, len(cc)

    findC := func(mana int) int {
        l, r := 0, k-1
        if d[l] > mana {
            return 0
        }

        for l < r {
            mid := (l+r+1) / 2
            if d[mid] > mana {
                r = mid - 1
            } else {
                l = mid
            }
        }

        return c[l]
    }

    ans := int64(n) * int64(s)
    for i := 0; i <= m; i++ {
        mana, speed := s, x
        if i < m && mana > b[i] {
            mana -= b[i]
            speed = a[i]
        }
        cnt := int64(max(n - findC(mana), 0))
        curAns := cnt * int64(speed)
        if curAns < ans {
            ans = curAns
        }
    }
    fmt.Println(ans)
}

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

package main

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

func solve() {
    n, m, k, x, s := readInt(), readInt(), readInt(), readInt(), readInt()
    a, b := readIntArray(m), readIntArray(m)
    c, d := readIntArray(k), readIntArray(k)

    findC := func(mana int) int {
        l, r := 0, k-1
        if d[l] > mana {
            return 0
        }

        for l < r {
            mid := (l+r+1) / 2
            if d[mid] > mana {
                r = mid - 1
            } else {
                l = mid
            }
        }

        return c[l]
    }

    ans := int64(n) * int64(s)
    for i := 0; i <= m; i++ {
        mana, speed := s, x
        if i < m && mana > b[i] {
            mana -= b[i]
            speed = a[i]
        }
        cnt := int64(max(n - findC(mana), 0))
        curAns := cnt * int64(speed)
        if curAns < ans {
            ans = curAns
        }
    }
    fmt.Println(ans)
}

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

package main

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

func solve() {
    n, m, k, x, s := readInt(), readInt(), readInt(), readInt(), readInt()
    a, b := readIntArray(m), readIntArray(m)
    c, d := readIntArray(k), readIntArray(k)

    findC := func(mana int) int {
        l, r := 0, k-1
        if d[l] > mana {
            return 0
        }

        for l < r {
            mid := (l+r+1) / 2
            if d[mid] > mana {
                r = mid - 1
            } else {
                l = mid
            }
        }

        return c[l]
    }

    ans := n * s
    for i := 0; i <= m; i++ {
        mana, speed := s, x
        if i < m && mana > b[i] {
            mana -= b[i]
            speed = a[i]
        }
        cnt := n - findC(mana)
        ans = min(ans, max(cnt, 0) * speed)
    }
    fmt.Println(ans)
}

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

package main

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

// MAX32 is
var MAX32 int32 = 2147483647

// MIN32 is
var MIN32 int32 = -2147483648

// MAX64 is
var MAX64 int64 = 9223372036854775807

// MIN64 is
var MIN64 int64 = -9223372036854775808

var scanner = bufio.NewScanner(os.Stdin)

var o = bufio.NewWriter(os.Stdout)

func init() {
	// scanner.Buffer()
	scanner.Split(bufio.ScanWords)
}
func end() {
	o.Flush()
}

var n int64
var m int32
var k int32
var x int64
var s int64
var ai []int64
var bi []int64
var ci []int64
var di []int64

func main() {
	defer end()
	n = ri64()             //task
	m = ri32()             // type 1 num
	k = ri32()             // type 2 num
	x = ri64()             // time
	s = ri64()             // mp
	ai = ri64sli(int64(m)) // type 1 xiaoguo
	bi = ri64sli(int64(m)) // type 1 mp
	ci = ri64sli(int64(k)) // type 2 xiaoguo
	di = ri64sli(int64(k)) //type 2 mp
	var last = MAX64
	for idx := int32(1); idx != m+1; idx++ {
		if bi[idx] <= s { // type 1 used
			mpleft := s - bi[idx]
			singletime := ai[idx]
			in := bsi64(di, 1, int64(k), mpleft)
			if in == int64(k+1) {
				in--
			} else if di[in] != mpleft {
				in--
			} else {
				for {
					if in+1 > int64(k) {
						break
					}
					if in+1 == mpleft {
						in++
					} else {
						break
					}
				}
			}
			lefttask := n - ci[in]
			wholetime := int64(singletime) * int64(lefttask)
			if wholetime < last {
				last = wholetime
			}
		} else { // type one not used
			mpleft := s
			singletime := x
			in := bsi64(di, 1, int64(k), mpleft)
			if in == int64(k+1) {
				in--
			} else if di[in] != mpleft {
				in--
			} else {
				for {
					if in+1 > int64(k) {
						break
					}
					if in+1 == mpleft {
						in++
					} else {
						break
					}
				}
			}
			lefttask := n - ci[in]
			wholetime := int64(singletime) * int64(lefttask)
			if wholetime < last {
				last = wholetime
			}
		}
	}
	oi(last)
	ostring("\n")
}

// IO
func ri32() int32 {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	n32 := int32(n)
	return n32
}
func ri32sli(nums int32) []int32 {
	re := make([]int32, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		re[idx] = ri32()
	}
	return re
}
func ri64() int64 {
	scanner.Scan()
	n64, _ := strconv.ParseInt(scanner.Text(), 0, 64)
	return n64
}
func ri64sli(nums int64) []int64 {
	re := make([]int64, nums+1, nums+1)
	for idx := int64(1); idx != nums+1; idx++ {
		re[idx] = ri64()
	}
	return re
}

func oi(i int64) {
	o.WriteString(fmt.Sprintf("%d", i))
}
func ostring(s string) {
	o.WriteString(s)
}

// math
func bsi64(s []int64, i, j, k int64) int64 {
	for {
		if i == j {
			if k <= s[i] {
				return i
			}
			if k > s[i] {
				return i + 1
			}
		}
		centeri := (i + j) / 2
		centerv := s[centeri]
		if k == centerv {
			return centeri
		}
		if k > centerv {
			i = centeri + 1
			continue
		}
		if k < centerv {
			j = centeri - 1
			if j < i {
				j = i
			}
			continue
		}
	}
}

package main

import "fmt"
import "sort"

// MAX32 is
var MAX32 int32 = 2147483647

// MIN32 is
var MIN32 int32 = -2147483648

// MAX64 is
var MAX64 int64 = 9223372036854775807

// MIN64 is
var MIN64 int64 = -9223372036854775808

func ri32(pn *int32) {
	fmt.Scanf("%d", pn)
}
func rai32(nums int32) []int32 {
	re := make([]int32, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		ri32(&re[idx])
	}
	return re
}

func ri64(pn *int64) {
	fmt.Scanf("%d", pn)
}
func rai64(nums int64) []int64 {
	re := make([]int64, nums+1, nums+1)
	for idx := int64(1); idx != nums+1; idx++ {
		ri64(&re[idx])
	}
	return re
}
func ri(pn *int) {
	fmt.Scanf("%d", pn)
}
func rai(nums int) []int {
	re := make([]int, nums+1, nums+1)
	for idx := int(1); idx != nums+1; idx++ {
		ri(&re[idx])
	}
	return re
}

func rstr(ps *string) {
	fmt.Scanf("%s", ps)
}
func rastr(nums int32) []string {
	re := make([]string, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		rstr(&re[idx])
	}
	return re
}

// OUT is
var OUT string

func oi32(i int32) {
	OUT += fmt.Sprintf("%d", i)
}
func oi64(i int64) {
	OUT += fmt.Sprintf("%d", i)
}

func oi32c(i int32, c string) {
	OUT += fmt.Sprintf("%d%s", i, c)
}
func oi64c(i int64, c string) {
	OUT += fmt.Sprintf("%d%s", i, c)
}

func oi32n(i int32) {
	oi32c(i, "\n")
}
func oi64n(i int64) {
	oi64c(i, "\n")
}

func oi32space(i int32) {
	oi32c(i, " ")
}
func oi64space(i int64) {
	oi64c(i, " ")
}

func ostring(s string) {
	OUT += s
}
func ob(b byte) {
	OUT += fmt.Sprintf("%c", b)
}

func p() {
	fmt.Print(OUT)
}

var N int32
var M int32
var K int32
var Time int32
var Mp int32
var S1 []int32
var S1mp []int32
var S2 []int32
var S2mp []int

func main() {
	ri32(&N)
	ri32(&M)
	ri32(&K)

	ri32(&Time)
	ri32(&Mp)

	S1 = rai32(M)
	S1mp = rai32(M)

	S2 = rai32(K)
	S2mp = rai(int(K))

	var zuihou int64 = MAX64
	for idx := int32(1); idx != M+1; idx++ {
		shengmp := Mp - S1mp[idx]
		f := sort.SearchInts(S2mp, int(shengmp))
		if int32(f) == K+1 {
			f = int(K)
		} else if S2mp[f] == int(shengmp) {

		} else {
			f = f - 1
		}
		renwuliang := N - S2[f]
		suan := int64(renwuliang) * int64(S1[idx])
		if suan < zuihou {
			zuihou = suan
		}
	}
	fmt.Println(zuihou)

}

package main

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

// MAX32 is
var MAX32 int32 = 2147483647

// MIN32 is
var MIN32 int32 = -2147483648

// MAX64 is
var MAX64 int64 = 9223372036854775807

// MIN64 is
var MIN64 int64 = -9223372036854775808

var scanner = bufio.NewScanner(os.Stdin)

var o = bufio.NewWriter(os.Stdout)

func init() {
	// scanner.Buffer()
	scanner.Split(bufio.ScanWords)
}
func end() {
	o.Flush()
}

var n int64
var m int32
var k int32
var x int64
var s int64
var ai []int64
var bi []int64
var ci []int64
var di []int64

func main() {
	defer end()
	n = ri64()             //task
	m = ri32()             // type 1 num
	k = ri32()             // type 2 num
	x = ri64()             // time
	s = ri64()             // mp
	ai = ri64sli(int64(m)) // type 1 xiaoguo
	bi = ri64sli(int64(m)) // type 1 mp
	ci = ri64sli(int64(k)) // type 2 xiaoguo
	di = ri64sli(int64(k)) //type 2 mp
	var last = MAX64
	for idx := int32(1); idx != m+1; idx++ {
		mpleft := s - bi[idx]
		var singletime int64
		if mpleft < 0 {
			mpleft = s
			singletime = x
		} else {
			singletime = ai[idx]
		}
		in := bsi64(di, mpleft)
		lefttask := n - ci[in]
		wholetime := int64(singletime) * int64(lefttask)
		if wholetime < last {
			last = wholetime
		}
	}
	oi(last)
	ostring("\n")
}

// IO
func ri32() int32 {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	n32 := int32(n)
	return n32
}
func ri32sli(nums int32) []int32 {
	re := make([]int32, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		re[idx] = ri32()
	}
	return re
}
func ri64() int64 {
	scanner.Scan()
	n64, _ := strconv.ParseInt(scanner.Text(), 0, 64)
	return n64
}
func ri64sli(nums int64) []int64 {
	re := make([]int64, nums+1, nums+1)
	for idx := int64(1); idx != nums+1; idx++ {
		re[idx] = ri64()
	}
	return re
}

func oi(i int64) {
	o.WriteString(fmt.Sprintf("%d", i))
}
func ostring(s string) {
	o.WriteString(s)
}

// math
func bsi64(s []int64, k int64) int64 {
	i := int64(0)
	j := int64(len(s) - 1)
	for i < j {
		m := (i + j + 1) / 2
		if s[m] <= k {
			i = m
		} else {
			j = m - 1
		}
	}
	return i
}

package main

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

// MAX32 is
var MAX32 int32 = 2147483647

// MIN32 is
var MIN32 int32 = -2147483648

// MAX64 is
var MAX64 int64 = 9223372036854775807

// MIN64 is
var MIN64 int64 = -9223372036854775808

var scanner = bufio.NewScanner(os.Stdin)

var o = bufio.NewWriter(os.Stdout)

func init() {
	// scanner.Buffer()
	scanner.Split(bufio.ScanWords)
}
func end() {
	o.Flush()
}

var n int64
var m int32
var k int32
var x int64
var s int64
var ai []int64
var bi []int64
var ci []int64
var di []int64

func main() {
	defer end()
	n = ri64()             //task
	m = ri32()             // type 1 num
	k = ri32()             // type 2 num
	x = ri64()             // time
	s = ri64()             // mp
	ai = ri64sli(int64(m)) // type 1 xiaoguo
	bi = ri64sli(int64(m)) // type 1 mp
	ci = ri64sli(int64(k)) // type 2 xiaoguo
	di = ri64sli(int64(k)) //type 2 mp
	var last = MAX64
	for idx := int32(1); idx != m+2; idx++ {
		var mpleft int64
		var singletime int64
		if idx == m+1 || s < ai[idx] {
			mpleft = s
			singletime = x
		} else {
			mpleft = s - ai[idx]
			singletime = ai[idx]
		}
		in := bsi64(di, mpleft)
		lefttask := n - ci[in]
		wholetime := int64(singletime) * int64(lefttask)
		if wholetime < last {
			last = wholetime
		}
	}
	oi(last)
	// if n == 1997320486 {
	// 	ostring(" ")
	// 	oi(int64(lastidx))
	// 	ostring(" ")
	// 	oi(lastin)
	// }
	ostring("\n")
}

// IO
func ri32() int32 {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	n32 := int32(n)
	return n32
}
func ri32sli(nums int32) []int32 {
	re := make([]int32, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		re[idx] = ri32()
	}
	return re
}
func ri64() int64 {
	scanner.Scan()
	n64, _ := strconv.ParseInt(scanner.Text(), 0, 64)
	return n64
}
func ri64sli(nums int64) []int64 {
	re := make([]int64, nums+1, nums+1)
	for idx := int64(1); idx != nums+1; idx++ {
		re[idx] = ri64()
	}
	return re
}

func oi(i int64) {
	o.WriteString(fmt.Sprintf("%d", i))
}
func ostring(s string) {
	o.WriteString(s)
}

// math
func bsi64(s []int64, k int64) int64 {
	i := int64(0)
	j := int64(len(s) - 1)
	for i < j {
		m := (i + j + 1) / 2
		if s[m] <= k {
			i = m
		} else {
			j = m - 1
		}
	}
	return i
}

package main

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

// MAX32 is
var MAX32 int32 = 2147483647

// MIN32 is
var MIN32 int32 = -2147483648

// MAX64 is
var MAX64 int64 = 9223372036854775807

// MIN64 is
var MIN64 int64 = -9223372036854775808

var scanner = bufio.NewScanner(os.Stdin)

var o = bufio.NewWriter(os.Stdout)

func init() {
	// scanner.Buffer()
	scanner.Split(bufio.ScanWords)
}
func end() {
	o.Flush()
}

var n int64
var m int32
var k int32
var x int64
var s int64
var ai []int64
var bi []int64
var ci []int64
var di []int64

func main() {
	defer end()
	n = ri64()             //task
	m = ri32()             // type 1 num
	k = ri32()             // type 2 num
	x = ri64()             // time
	s = ri64()             // mp
	ai = ri64sli(int64(m)) // type 1 xiaoguo
	bi = ri64sli(int64(m)) // type 1 mp
	ci = ri64sli(int64(k)) // type 2 xiaoguo
	di = ri64sli(int64(k)) //type 2 mp
	var last = MAX64
	for idx := int32(1); idx != m+2; idx++ {
		var mpleft int64
		var singletime int64
		if idx == m+1 || s < ai[idx] {
			mpleft = s
			singletime = x
		} else {
			mpleft = s - bi[idx]
			singletime = ai[idx]
		}
		in := bsi64(di, mpleft)
		lefttask := n - ci[in]
		wholetime := int64(singletime) * int64(lefttask)
		if wholetime < last {
			last = wholetime
		}
	}
	oi(last)
	// if n == 1997320486 {
	// 	ostring(" ")
	// 	oi(int64(lastidx))
	// 	ostring(" ")
	// 	oi(lastin)
	// }
	ostring("\n")
}

// IO
func ri32() int32 {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	n32 := int32(n)
	return n32
}
func ri32sli(nums int32) []int32 {
	re := make([]int32, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		re[idx] = ri32()
	}
	return re
}
func ri64() int64 {
	scanner.Scan()
	n64, _ := strconv.ParseInt(scanner.Text(), 0, 64)
	return n64
}
func ri64sli(nums int64) []int64 {
	re := make([]int64, nums+1, nums+1)
	for idx := int64(1); idx != nums+1; idx++ {
		re[idx] = ri64()
	}
	return re
}

func oi(i int64) {
	o.WriteString(fmt.Sprintf("%d", i))
}
func ostring(s string) {
	o.WriteString(s)
}

// math
func bsi64(s []int64, k int64) int64 {
	i := int64(0)
	j := int64(len(s) - 1)
	for i < j {
		m := (i + j + 1) / 2
		if s[m] <= k {
			i = m
		} else {
			j = m - 1
		}
	}
	return i
}

package main

import "fmt"
import "sort"

// MAX32 is
var MAX32 int32 = 2147483647

// MIN32 is
var MIN32 int32 = -2147483648

// MAX64 is
var MAX64 int64 = 9223372036854775807

// MIN64 is
var MIN64 int64 = -9223372036854775808

func ri32(pn *int32) {
	fmt.Scanf("%d", pn)
}
func rai32(nums int32) []int32 {
	re := make([]int32, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		ri32(&re[idx])
	}
	return re
}

func ri64(pn *int64) {
	fmt.Scanf("%d", pn)
}
func rai64(nums int64) []int64 {
	re := make([]int64, nums+1, nums+1)
	for idx := int64(1); idx != nums+1; idx++ {
		ri64(&re[idx])
	}
	return re
}
func ri(pn *int) {
	fmt.Scanf("%d", pn)
}
func rai(nums int) []int {
	re := make([]int, nums+1, nums+1)
	for idx := int(1); idx != nums+1; idx++ {
		ri(&re[idx])
	}
	return re
}

func rstr(ps *string) {
	fmt.Scanf("%s", ps)
}
func rastr(nums int32) []string {
	re := make([]string, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		rstr(&re[idx])
	}
	return re
}

// OUT is
var OUT string

func oi32(i int32) {
	OUT += fmt.Sprintf("%d", i)
}
func oi64(i int64) {
	OUT += fmt.Sprintf("%d", i)
}

func oi32c(i int32, c string) {
	OUT += fmt.Sprintf("%d%s", i, c)
}
func oi64c(i int64, c string) {
	OUT += fmt.Sprintf("%d%s", i, c)
}

func oi32n(i int32) {
	oi32c(i, "\n")
}
func oi64n(i int64) {
	oi64c(i, "\n")
}

func oi32space(i int32) {
	oi32c(i, " ")
}
func oi64space(i int64) {
	oi64c(i, " ")
}

func ostring(s string) {
	OUT += s
}
func ob(b byte) {
	OUT += fmt.Sprintf("%c", b)
}

func p() {
	fmt.Print(OUT)
}

var N int32
var M int32
var K int32
var Time int32
var Mp int32
var S1 []int32
var S1mp []int32
var S2 []int32
var S2mp []int

func main() {
	ri32(&N)
	ri32(&M)
	ri32(&K)

	ri32(&Time)
	ri32(&Mp)

	S1 = rai32(M)
	S1mp = rai32(M)

	S2 = rai32(K)
	S2mp = rai(int(K))

	var zuihou int64 = MAX64
	for idx := int32(1); idx != M+1; idx++ {
		shengmp := Mp - S1mp[idx]
		f := sort.SearchInts(S2mp, int(shengmp))
		if int32(f) == K+1 {
			f = int(K)
		} else if S2mp[f] == int(shengmp) {

		} else {
			f = f - 1
		}
		renwuliang := N - S2[f]
		suan := int64(renwuliang) * int64(S1[idx])
		if suan < zuihou {
			zuihou = suan
		}
	}
	fmt.Println(20)

}

package main

import "fmt"
import "sort"

// MAX32 is
var MAX32 int32 = 2147483647

// MIN32 is
var MIN32 int32 = -2147483648

// MAX64 is
var MAX64 int64 = 9223372036854775807

// MIN64 is
var MIN64 int64 = -9223372036854775808

func ri32(pn *int32) {
	fmt.Scanf("%d", pn)
}
func rai32(nums int32) []int32 {
	re := make([]int32, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		ri32(&re[idx])
	}
	return re
}

func ri64(pn *int64) {
	fmt.Scanf("%d", pn)
}
func rai64(nums int64) []int64 {
	re := make([]int64, nums+1, nums+1)
	for idx := int64(1); idx != nums+1; idx++ {
		ri64(&re[idx])
	}
	return re
}
func ri(pn *int) {
	fmt.Scanf("%d", pn)
}
func rai(nums int) []int {
	re := make([]int, nums+1, nums+1)
	for idx := int(1); idx != nums+1; idx++ {
		ri(&re[idx])
	}
	return re
}

func rstr(ps *string) {
	fmt.Scanf("%s", ps)
}
func rastr(nums int32) []string {
	re := make([]string, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		rstr(&re[idx])
	}
	return re
}

// OUT is
var OUT string

func oi32(i int32) {
	OUT += fmt.Sprintf("%d", i)
}
func oi64(i int64) {
	OUT += fmt.Sprintf("%d", i)
}

func oi32c(i int32, c string) {
	OUT += fmt.Sprintf("%d%s", i, c)
}
func oi64c(i int64, c string) {
	OUT += fmt.Sprintf("%d%s", i, c)
}

func oi32n(i int32) {
	oi32c(i, "\n")
}
func oi64n(i int64) {
	oi64c(i, "\n")
}

func oi32space(i int32) {
	oi32c(i, " ")
}
func oi64space(i int64) {
	oi64c(i, " ")
}

func ostring(s string) {
	OUT += s
}
func ob(b byte) {
	OUT += fmt.Sprintf("%c", b)
}

func p() {
	fmt.Print(OUT)
}

var N int32
var M int32
var K int32
var Time int32
var Mp int32
var S1 []int32
var S1mp []int32
var S2 []int32
var S2mp []int

func main() {
	// scanner := bufio.NewScanner(os.Stdin)
	// var i = 0
	// for scanner.Scan() {
	// 	if i == 0 {

	// 		s := scanner.Text()
	// 	} else if i == 1 {

	// 	} else if i == 2 {

	// 	} else if i == 3 {

	// 	} else if i == 4 {

	// 	}

	// }
	ri32(&N)
	ri32(&M)
	ri32(&K)

	ri32(&Time)
	ri32(&Mp)

	S1 = rai32(M)
	S1mp = rai32(M)

	S2 = rai32(K)
	S2mp = rai(int(K))

	var zuihou int64 = MAX64
	for idx := int32(1); idx != M+1; idx++ {
		shengmp := Mp - S1mp[idx]
		f := sort.SearchInts(S2mp, int(shengmp))
		if int32(f) == K+1 {
			f = int(K)
		} else if S2mp[f] == int(shengmp) {

		} else {
			f = f - 1
		}
		renwuliang := N - S2[f]
		suan := int64(renwuliang) * int64(S1[idx])
		if suan < zuihou {
			zuihou = suan
		}
	}
	zuihou = 20
	fmt.Println(zuihou)

}

package main

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

// MAX32 is
var MAX32 int32 = 2147483647

// MIN32 is
var MIN32 int32 = -2147483648

// MAX64 is
var MAX64 int64 = 9223372036854775807

// MIN64 is
var MIN64 int64 = -9223372036854775808

var scanner = bufio.NewScanner(os.Stdin)

var o = bufio.NewWriter(os.Stdout)

func init() {
	// scanner.Buffer()
	scanner.Split(bufio.ScanWords)
}
func end() {
	o.Flush()
}

var n int64
var m int32
var k int32
var x int64
var s int64
var ai []int64
var bi []int64
var ci []int64
var di []int64

func main() {
	defer end()
	n = ri64()             //task
	m = ri32()             // type 1 num
	k = ri32()             // type 2 num
	x = ri64()             // time
	s = ri64()             // mp
	ai = ri64sli(int64(m)) // type 1 xiaoguo
	bi = ri64sli(int64(m)) // type 1 mp
	ci = ri64sli(int64(k)) // type 2 xiaoguo
	di = ri64sli(int64(k)) //type 2 mp
	var last = MAX64
	for idx := int32(1); idx != m+1; idx++ {
		if bi[idx] <= s { // type 1 used
			mpleft := s - bi[idx]
			singletime := ai[idx]
			in := bsi64(di, 1, int64(k), mpleft)
			if in == int64(k+1) {
				in--
			} else if di[in] != mpleft {
				in--
			} else {
				for {
					if in+1 > int64(k) {
						break
					}
					if di[in+1] == mpleft {
						in++
					} else {
						break
					}
				}
			}
			lefttask := n - ci[in]
			wholetime := int64(singletime) * int64(lefttask)
			if wholetime < last {
				last = wholetime
			}
		} else { // type one not used
			mpleft := s
			singletime := x
			in := bsi64(di, 1, int64(k), mpleft)
			if in == int64(k+1) {
				in--
			} else if di[in] != mpleft {
				in--
			} else {
				for {
					if in+1 > int64(k) {
						break
					}
					if di[in+1] == mpleft {
						in++
					} else {
						break
					}
				}
			}
			lefttask := n - ci[in]
			wholetime := int64(singletime) * int64(lefttask)
			if wholetime < last {
				last = wholetime
			}
		}
	}
	oi(last)
	ostring("\n")
}

// IO
func ri32() int32 {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	n32 := int32(n)
	return n32
}
func ri32sli(nums int32) []int32 {
	re := make([]int32, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		re[idx] = ri32()
	}
	return re
}
func ri64() int64 {
	scanner.Scan()
	n64, _ := strconv.ParseInt(scanner.Text(), 0, 64)
	return n64
}
func ri64sli(nums int64) []int64 {
	re := make([]int64, nums+1, nums+1)
	for idx := int64(1); idx != nums+1; idx++ {
		re[idx] = ri64()
	}
	return re
}

func oi(i int64) {
	o.WriteString(fmt.Sprintf("%d", i))
}
func ostring(s string) {
	o.WriteString(s)
}

// math
func bsi64(s []int64, i, j, k int64) int64 {
	for {
		if i == j {
			if k <= s[i] {
				return i
			}
			if k > s[i] {
				return i + 1
			}
		}
		centeri := (i + j) / 2
		centerv := s[centeri]
		if k == centerv {
			return centeri
		}
		if k > centerv {
			i = centeri + 1
			continue
		}
		if k < centerv {
			j = centeri - 1
			if j < i {
				j = i
			}
			continue
		}
	}
}

package main

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

// MAX32 is
var MAX32 int32 = 2147483647

// MIN32 is
var MIN32 int32 = -2147483648

// MAX64 is
var MAX64 int64 = 9223372036854775807

// MIN64 is
var MIN64 int64 = -9223372036854775808

var scanner = bufio.NewScanner(os.Stdin)

var o = bufio.NewWriter(os.Stdout)

func init() {
	// scanner.Buffer()
	scanner.Split(bufio.ScanWords)
}
func end() {
	o.Flush()
}

var n int32
var m int32
var k int32
var ai []int32
var bi []int32
var ci []int32
var di []int32

func main() {
	defer end()
	n := ri32()     //task
	m := ri32()     // type 1 num
	k := ri32()     // type 2 num
	x := ri32()     // time
	s := ri32()     // mp
	ai = ri32sli(m) // type 1 xiaoguo
	bi = ri32sli(m) // type 1 mp
	ci = ri32sli(k) // type 2 xiaoguo
	di = ri32sli(k) //type 2 mp
	var last = MAX64
	for idx := int32(1); idx != m+1; idx++ {
		if bi[idx] <= s { // type 1 used
			mpleft := s - bi[idx]
			singletime := ai[idx]
			in := bsi32(di, 1, k, mpleft)
			if in == k+1 {
				in--
			} else if di[in] != mpleft {
				in--
			} else {
				for {
					if in+1 > k {
						break
					}
					if in+1 == mpleft {
						in++
					} else {
						break
					}
				}
			}
			lefttask := n - ci[in]
			wholetime := int64(singletime) * int64(lefttask)
			if wholetime < last {
				last = wholetime
			}
		} else { // type one not used
			mpleft := s
			singletime := x
			in := bsi32(di, 1, k, mpleft)
			if in == k+1 {
				in--
			} else if di[in] != mpleft {
				in--
			} else {
				for {
					if in+1 > k {
						break
					}
					if in+1 == mpleft {
						in++
					} else {
						break
					}
				}
			}
			lefttask := n - ci[in]
			wholetime := int64(singletime) * int64(lefttask)
			if wholetime < last {
				last = wholetime
			}
		}
	}
	oi(last)
	ostring("\n")
}

// IO
func ri32() int32 {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	n32 := int32(n)
	return n32
}
func ri32sli(nums int32) []int32 {
	re := make([]int32, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		re[idx] = ri32()
	}
	return re
}
func oi(i int64) {
	o.WriteString(fmt.Sprintf("%d", i))
}
func ostring(s string) {
	o.WriteString(s)
}

// math
func bsi32(s []int32, i, j, k int32) int32 {
	for {
		if i == j {
			if k <= s[i] {
				return i
			}
			if k > s[i] {
				return i + 1
			}
		}
		centeri := (i + j) / 2
		centerv := s[centeri]
		if k == centerv {
			return centeri
		}
		if k > centerv {
			i = centeri + 1
			continue
		}
		if k < centerv {
			j = centeri - 1
			if j < i {
				j = i
			}
			continue
		}
	}
}

package main

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

// MAX32 is
var MAX32 int32 = 2147483647

// MIN32 is
var MIN32 int32 = -2147483648

// MAX64 is
var MAX64 int64 = 9223372036854775807

// MIN64 is
var MIN64 int64 = -9223372036854775808

var scanner = bufio.NewScanner(os.Stdin)

var o = bufio.NewWriter(os.Stdout)

func init() {
	// scanner.Buffer()
	scanner.Split(bufio.ScanWords)
}
func end() {
	o.Flush()
}

var n int64
var m int32
var k int32
var x int64
var s int64
var ai []int64
var bi []int64
var ci []int64
var di []int64

func main() {
	defer end()
	n = ri64()             //task
	m = ri32()             // type 1 num
	k = ri32()             // type 2 num
	x = ri64()             // time
	s = ri64()             // mp
	ai = ri64sli(int64(m)) // type 1 xiaoguo
	bi = ri64sli(int64(m)) // type 1 mp
	ci = ri64sli(int64(k)) // type 2 xiaoguo
	di = ri64sli(int64(k)) //type 2 mp
	var last = MAX64
	var lastidx int32
	var lastin int64
	for idx := int32(1); idx != m+1; idx++ {
		mpleft := s - bi[idx]
		var singletime int64
		if mpleft < 0 {
			mpleft = s
			singletime = x
		} else {
			singletime = ai[idx]
		}
		in := bsi64(di, mpleft)
		lefttask := n - ci[in]
		wholetime := int64(singletime) * int64(lefttask)
		if wholetime < last {
			lastin = in
			last = wholetime
			lastidx = idx
		}
	}
	oi(last)
	if n == 1997320486 {
		ostring(" ")
		oi(int64(lastidx))
		ostring(" ")
		oi(lastin)
	}
	ostring("\n")
}

// IO
func ri32() int32 {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	n32 := int32(n)
	return n32
}
func ri32sli(nums int32) []int32 {
	re := make([]int32, nums+1, nums+1)
	for idx := int32(1); idx != nums+1; idx++ {
		re[idx] = ri32()
	}
	return re
}
func ri64() int64 {
	scanner.Scan()
	n64, _ := strconv.ParseInt(scanner.Text(), 0, 64)
	return n64
}
func ri64sli(nums int64) []int64 {
	re := make([]int64, nums+1, nums+1)
	for idx := int64(1); idx != nums+1; idx++ {
		re[idx] = ri64()
	}
	return re
}

func oi(i int64) {
	o.WriteString(fmt.Sprintf("%d", i))
}
func ostring(s string) {
	o.WriteString(s)
}

// math
func bsi64(s []int64, k int64) int64 {
	i := int64(0)
	j := int64(len(s) - 1)
	for i < j {
		m := (i + j + 1) / 2
		if s[m] <= k {
			i = m
		} else {
			j = m - 1
		}
	}
	return i
}

// Codeforces 734 C AntonMakingPotions,
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"strconv"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for j:=0; j<n; j++ {
		aa,err := strconv.Atoi(ss[j])
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[j] = aa
	}
	return a
}

var n,m,k int
var x,s int
var a []int
var b []int
var c []int
var d []int

var minTime int64

func readData() {
	in = bufio.NewReader(os.Stdin)
	// reading field
	n,m,k,_,_ = readFive()
	x,s,_,_,_ = readFive()
	a = readLineNumbs(m)
	b = readLineNumbs(m)
	c = readLineNumbs(k)
	d = readLineNumbs(k)
}

func binFindMaxLessd(lman int) int {
	if lman<d[0] {
		return -1
	}
	i0 := 0
	i1 := k
	for i1 > i0 {
		ii := (i0 + i1)/2
		//fmt.Printf("ii,i0,i1 = %d %d %d d[ii],lman = %d %d\n",ii,i0,i1,d[ii],lman)
		if ii==i0 {
			break
		} else if d[ii] <= lman {
			i0 = ii
		} else {
			i1 = ii
		}
	}
	//fmt.Printf("binFindMaxLessd(), lman i0 = %d %d\n", lman, i0)
	return i0
}

func solve() {
	minTime = int64(n)*int64(x)
	a = append(a, int(x))
	b = append(b, 0)
	for i:=0; i<m; i++ {
		if b[i] <= s {
			o := s-b[i]
			nskip := 0
			didx := binFindMaxLessd(o)
			if didx>=0 {
				nskip = c[didx]
			}
			ctime := int64(a[i]) * int64(n-nskip)
			if ctime < minTime {
				minTime = ctime
			}
		}
	}
}

func printRes() {
	fmt.Println(minTime)
}

func main() {
	readData()
	solve()
	printRes()
}

package main

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

const MAX_MK = 200010

var N int64
var M, K int
var X, S int64
var A [MAX_MK]int64
var B [MAX_MK]int64
var C [MAX_MK]int64
var D [MAX_MK]int64

func lowerBound(mana int64) int64 {
	var left, right int
	left = 0
	right = int(K)
	var result int64
	result = 0
	for right-left > 1 {
		med := (right + left) / 2
		reqMana := D[med]
		if reqMana > mana {
			right = med
		} else {
			left = med
			result = C[med]
		}
	}
	return result
}

func solve() {
	var result int64
	result = 1 << 50
	for i := 0; i < int(M+1); i++ {
		var pre, mana int64
		if i == int(M) {
			pre = X
			mana = S
		} else if i < int(M) && B[i] <= S {
			pre = A[i]
			mana = S - B[i]
		} else {
			pre = X
			mana = S
		}
		var needPotions int64
		needPotions = N
		needPotions -= lowerBound(mana)
		if needPotions <= 0 {
			result = 0
			break
		}

		if needPotions*pre < result {
			result = needPotions * pre
		}
		//fmt.Println(i, needPotions, pre)
		//fmt.Println(i, needPotions*pre)
	}
	fmt.Println(result)
}

func main() {
	fsc := NewFastScanner()
	N, M, K = fsc.NextInt64(), fsc.NextInt(), fsc.NextInt()
	X, S = fsc.NextInt64(), fsc.NextInt64()
	for i := 0; i < M; i++ {
		A[i] = fsc.NextInt64()
	}
	for i := 0; i < M; i++ {
		B[i] = fsc.NextInt64()
	}

	for i := 0; i < K; i++ {
		C[i] = fsc.NextInt64()
	}
	for i := 0; i < K; i++ {
		D[i] = fsc.NextInt64()
	}
	solve()
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 2028)
	return &FastScanner{r: rdr}
}

func (s *FastScanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *FastScanner) NextInt() int {
	val, err := strconv.Atoi(s.Next())
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) NextInt64() int64 {
	val, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}

func (s *FastScanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, err := s.r.ReadLine()
		if err != nil {
			panic(err.Error())
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

const MAX_MK = 200010

var N int64
var M, K int
var X, S int64
var A [MAX_MK]int64
var B [MAX_MK]int64
var C [MAX_MK]int64
var D [MAX_MK]int64

func lowerBound(mana int64) int64 {
	var left, right int
	left = -10
	right = K + 10
	var result int64
	result = 0
	for right-left > 1 {
		med := (right + left) / 2
		//fmt.Println("med", med)
		if med < 0 {
			left = med
			continue
		}
		if med > K-1 {
			right = med
			continue
		}
		reqMana := D[med]
		if reqMana > mana {
			right = med
		} else {
			left = med
			result = C[med]
		}
	}
	return result
}

func solve() {
	var result int64
	result = 1 << 50
	for i := 0; i < int(M+1); i++ {
		var pre, mana int64
		if i < int(M) && B[i] <= S {
			pre = A[i]
			mana = S - B[i]
		} else {
			pre = X
			mana = S
		}
		var needPotions int64
		needPotions = N
		needPotions -= lowerBound(mana)
		if needPotions <= 0 {
			result = 0
			break
		}

		if needPotions*pre < result {
			result = needPotions * pre
		}
		//fmt.Println(i, needPotions, pre)
		//fmt.Println(i, needPotions*pre)
	}
	fmt.Println(result)
}

func main() {
	fsc := NewFastScanner()
	N, M, K = fsc.NextInt64(), fsc.NextInt(), fsc.NextInt()
	X, S = fsc.NextInt64(), fsc.NextInt64()
	for i := 0; i < M; i++ {
		A[i] = fsc.NextInt64()
	}
	for i := 0; i < M; i++ {
		B[i] = fsc.NextInt64()
	}

	for i := 0; i < K; i++ {
		C[i] = fsc.NextInt64()
	}
	for i := 0; i < K; i++ {
		D[i] = fsc.NextInt64()
	}
	solve()
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 2028)
	return &FastScanner{r: rdr}
}

func (s *FastScanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *FastScanner) NextInt() int {
	val, err := strconv.Atoi(s.Next())
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) NextInt64() int64 {
	val, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}

func (s *FastScanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, err := s.r.ReadLine()
		if err != nil {
			panic(err.Error())
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

const MAX_MK = 200010

var N int64
var M, K int
var X, S int64
var A [MAX_MK]int64
var B [MAX_MK]int64
var C [MAX_MK]int64
var D [MAX_MK]int64

func lowerBound(mana int64) int64 {
	var left, right int
	left = -10
	right = K + 10
	var result int64
	result = 0
	for right-left > 1 {
		med := (right + left) / 2
		//fmt.Println("med", med)
		if med < 0 {
			left = med
			continue
		}
		if med > K-1 {
			right = med
			continue
		}
		reqMana := D[med]
		if reqMana > mana {
			right = med
		} else {
			left = med
			result = C[med]
		}
	}
	return result
}

func solve() {
	var result int64
	result = 1 << 60
	for i := 0; i < int(M+1); i++ {
		var pre, mana int64
		if i < int(M) && B[i] <= S {
			pre = A[i]
			mana = S - B[i]
		} else {
			pre = X
			mana = S
		}
		var needPotions int64
		needPotions = N
		needPotions -= lowerBound(mana)
		if needPotions <= 0 {
			result = 0
			break
		}

		if needPotions*pre < result {
			result = needPotions * pre
		}
		//fmt.Println(i, needPotions, pre)
		//fmt.Println(i, needPotions*pre)
	}
	fmt.Println(result)
}

func main() {
	fsc := NewFastScanner()
	N, M, K = fsc.NextInt64(), fsc.NextInt(), fsc.NextInt()
	X, S = fsc.NextInt64(), fsc.NextInt64()
	for i := 0; i < M; i++ {
		A[i] = fsc.NextInt64()
	}
	for i := 0; i < M; i++ {
		B[i] = fsc.NextInt64()
	}

	for i := 0; i < K; i++ {
		C[i] = fsc.NextInt64()
	}
	for i := 0; i < K; i++ {
		D[i] = fsc.NextInt64()
	}
	solve()
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 2028)
	return &FastScanner{r: rdr}
}

func (s *FastScanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *FastScanner) NextInt() int {
	val, err := strconv.Atoi(s.Next())
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) NextInt64() int64 {
	val, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}

func (s *FastScanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, err := s.r.ReadLine()
		if err != nil {
			panic(err.Error())
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, m, q := readThreeNums(reader)
		edges := make([][]int, m)
		for i := 0; i < m; i++ {
			edges[i] = readNNums(reader, 2)
		}
		Q := make([][]int, q)
		for i := 0; i < q; i++ {
			Q[i] = readNNums(reader, 2)
		}
		res := solve(n, edges, Q)
		for i := 0; i < q; i++ {
			buf.WriteString(fmt.Sprintf("%d ", res[i]))
		}
		buf.WriteByte('\n')
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const H = 20

func solve(n int, edges [][]int, Q [][]int) []int {
	set := NewUF(n)

	F := make([]int, n)

	groups := make([][]int, n)
	for i := 0; i < n; i++ {
		groups[i] = make([]int, 0, 1)
		groups[i] = append(groups[i], i)
	}

	for i, edge := range edges {
		u, v := edge[0], edge[1]
		u--
		v--
		pu := set.Find(u)
		pv := set.Find(v)
		if pu == pv {
			continue
		}
		// will connect
		if set.sz[pu] < set.sz[pv] {
			pu, pv = pv, pu
		}
		// sz[pu] > sz[pv]
		for _, x := range groups[pv] {
			if x > 0 && set.Find(x-1) == pu {
				F[x] = i + 1
			}
			if x+1 < n && set.Find(x+1) == pu {
				F[x+1] = i + 1
			}
		}

		set.sz[pu] += set.sz[pv]
		set.arr[pv] = pu
		groups[pu] = append(groups[pu], groups[pv]...)
	}

	return findAns(n, F, Q)
}

func solve1(n int, edges [][]int, Q [][]int) []int {

	g := NewGraph(n, 2*(n-1))

	set := NewUF(n)

	for i, edge := range edges {
		u, v := edge[0], edge[1]
		u--
		v--
		if set.Union(u, v) {
			g.AddEdge(u, v, i+1)
			g.AddEdge(v, u, i+1)
		}
	}

	D := make([]int, n)
	P := make([][]int, n)
	C := make([][]int, n)
	var dfs func(p, u, w int)

	dfs = func(p, u, w int) {
		P[u] = make([]int, H)
		C[u] = make([]int, H)
		P[u][0] = p
		C[u][0] = w
		for i := 1; i < H; i++ {
			x := P[u][i-1]
			P[u][i] = P[x][i-1]
			C[u][i] = max(C[u][i-1], C[x][i-1])
		}

		for i := g.node[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p != v {
				D[v] = D[u] + 1
				dfs(u, v, g.cost[i])
			}
		}
	}

	dfs(0, 0, 0)

	find_cost := func(u int, v int) int {
		if D[u] < D[v] {
			u, v = v, u
		}
		var res int
		for i := H - 1; i >= 0; i-- {
			if (D[u] - (1 << i)) >= D[v] {
				res = max(res, C[u][i])
				u = P[u][i]
			}
		}
		if u == v {
			return res
		}

		for i := H - 1; i >= 0; i-- {
			if P[u][i] != P[v][i] {
				res = max(res, C[u][i])
				res = max(res, C[v][i])
				u = P[u][i]
				v = P[v][i]
			}
		}
		return max(max(res, C[u][0]), C[v][0])
	}

	// F[i] = max_cost to connect i & i - 1
	F := make([]int, n)

	for i := 1; i < n; i++ {
		F[i] = find_cost(i-1, i)
	}

	return findAns(n, F, Q)
}

func findAns(n int, F []int, Q [][]int) []int {
	arr := make([]int, 2*n)

	copy(arr[n:], F)

	for i := n - 1; i > 0; i-- {
		arr[i] = max(arr[i*2], arr[i*2+1])
	}

	get := func(l, r int) int {
		l += n
		r += n
		var res int

		for l < r {
			if l&1 == 1 {
				res = max(res, arr[l])
				l++
			}
			if r&1 == 1 {
				r--
				res = max(res, arr[r])
			}
			l >>= 1
			r >>= 1
		}
		return res
	}

	ans := make([]int, len(Q))
	for i := 0; i < len(Q); i++ {
		l, r := Q[i][0]-1, Q[i][1]
		ans[i] = get(l+1, r)
	}
	return ans
}

type Graph struct {
	node []int
	next []int
	to   []int
	cost []int
	cur  int
}

func NewGraph(n int, e int) *Graph {
	g := new(Graph)
	g.node = make([]int, n)
	g.next = make([]int, e+1)
	g.to = make([]int, e+1)
	g.cost = make([]int, e+1)
	g.cur = 0
	return g
}

func (g *Graph) AddEdge(u, v, w int) {
	g.cur++
	g.next[g.cur] = g.node[u]
	g.node[u] = g.cur
	g.to[g.cur] = v
	g.cost[g.cur] = w
}

type UF struct {
	arr []int
	sz  []int
}

func NewUF(n int) *UF {
	arr := make([]int, n)
	sz := make([]int, n)
	for i := 0; i < n; i++ {
		sz[i]++
		arr[i] = i
	}

	return &UF{arr, sz}
}

func (uf *UF) Find(x int) int {
	if uf.arr[x] != x {
		uf.arr[x] = uf.Find(uf.arr[x])
	}
	return uf.arr[x]
}

func (uf *UF) Union(a, b int) bool {
	pa := uf.Find(a)
	pb := uf.Find(b)
	if pa == pb {
		return false
	}
	if uf.sz[pa] < uf.sz[pb] {
		pa, pb = pb, pa
	}

	uf.sz[pa] += uf.sz[pb]
	uf.arr[pb] = pa
	return true
}

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, m, q := readThreeNums(reader)
		edges := make([][]int, m)
		for i := 0; i < m; i++ {
			edges[i] = readNNums(reader, 2)
		}
		Q := make([][]int, q)
		for i := 0; i < q; i++ {
			Q[i] = readNNums(reader, 2)
		}
		res := solve(n, edges, Q)
		for i := 0; i < q; i++ {
			buf.WriteString(fmt.Sprintf("%d ", res[i]))
		}
		buf.WriteByte('\n')
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const H = 20

func solve(n int, edges [][]int, Q [][]int) []int {

	g := NewGraph(n, 2*(n-1))

	set := NewUF(n)

	for i, edge := range edges {
		u, v := edge[0], edge[1]
		u--
		v--
		if set.Union(u, v) {
			g.AddEdge(u, v, i+1)
			g.AddEdge(v, u, i+1)
		}
	}

	D := make([]int, n)
	P := make([][]int, n)
	C := make([][]int, n)
	var dfs func(p, u, w int)

	dfs = func(p, u, w int) {
		P[u] = make([]int, H)
		C[u] = make([]int, H)
		P[u][0] = p
		C[u][0] = w
		for i := 1; i < H; i++ {
			x := P[u][i-1]
			P[u][i] = P[x][i-1]
			C[u][i] = max(C[u][i-1], C[x][i-1])
		}

		for i := g.node[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p != v {
				D[v] = D[u] + 1
				dfs(u, v, g.cost[i])
			}
		}
	}

	dfs(0, 0, 0)

	find_cost := func(u int, v int) int {
		if D[u] < D[v] {
			u, v = v, u
		}
		var res int
		for i := H - 1; i >= 0; i-- {
			if (D[u] - (1 << i)) >= D[v] {
				res = max(res, C[u][i])
				u = P[u][i]
			}
		}
		if u == v {
			return res
		}

		for i := H - 1; i >= 0; i-- {
			if P[u][i] != P[v][i] {
				res = max(res, C[u][i])
				res = max(res, C[v][i])
				u = P[u][i]
				v = P[v][i]
			}
		}
		return max(max(res, C[u][0]), C[v][0])
	}

	// F[i] = max_cost to connect i & i - 1
	F := make([]int, n)

	for i := 1; i < n; i++ {
		F[i] = find_cost(i-1, i)
	}

	arr := make([]int, 2*n)

	copy(arr[n:], F)

	for i := n - 1; i > 0; i-- {
		arr[i] = max(arr[i*2], arr[i*2+1])
	}

	get := func(l, r int) int {
		l += n
		r += n
		var res int

		for l < r {
			if l&1 == 1 {
				res = max(res, arr[l])
				l++
			}
			if r&1 == 1 {
				r--
				res = max(res, arr[r])
			}
			l >>= 1
			r >>= 1
		}
		return res
	}

	ans := make([]int, len(Q))
	for i := 0; i < len(Q); i++ {
		l, r := Q[i][0]-1, Q[i][1]
		ans[i] = get(l+1, r)
	}
	return ans
}

type Graph struct {
	node []int
	next []int
	to   []int
	cost []int
	cur  int
}

func NewGraph(n int, e int) *Graph {
	g := new(Graph)
	g.node = make([]int, n)
	g.next = make([]int, e+1)
	g.to = make([]int, e+1)
	g.cost = make([]int, e+1)
	g.cur = 0
	return g
}

func (g *Graph) AddEdge(u, v, w int) {
	g.cur++
	g.next[g.cur] = g.node[u]
	g.node[u] = g.cur
	g.to[g.cur] = v
	g.cost[g.cur] = w
}

type UF struct {
	arr []int
	sz  []int
}

func NewUF(n int) *UF {
	arr := make([]int, n)
	sz := make([]int, n)
	for i := 0; i < n; i++ {
		sz[i]++
		arr[i] = i
	}

	return &UF{arr, sz}
}

func (uf *UF) Find(x int) int {
	if uf.arr[x] != x {
		uf.arr[x] = uf.Find(uf.arr[x])
	}
	return uf.arr[x]
}

func (uf *UF) Union(a, b int) bool {
	pa := uf.Find(a)
	pb := uf.Find(b)
	if pa == pb {
		return false
	}
	if uf.sz[pa] < uf.sz[pb] {
		pa, pb = pb, pa
	}

	uf.sz[pa] += uf.sz[pb]
	uf.arr[pb] = pa
	return true
}

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

package main

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

const MOD int64 = 1000000007

var n, m, q int

var a[][2]int

var qu [][2]int

var maxEdge[]int
var log []int

var mps []*map[int]bool

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

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

type Item struct {
	rightEnd int
	divideBy int
}

const LOCAL = false

type segmentTree struct {
	n int
	t []int64
}

func create(n int) *segmentTree {
	return &segmentTree{n : n, t : make([]int64, 4 * n)}
}

func (s *segmentTree) build(a []int64, v int, tl int, tr int) {
	if tl == tr {
		s.t[v] = a[tl]
	} else {
		tm := (tl + tr) / 2;
		s.build(a, v*2, tl, tm)
		s.build(a, v*2+1, tm+1, tr)
		s.t[v] = max(s.t[v*2], s.t[v*2+1])
	}
}

func (s *segmentTree) get(v int, tl int, tr int, l int, r int) int64 {
	if l > r {
		return 0
	}
	if l == tl && r == tr {
		return s.t[v]
	}

	tm := (tl + tr) / 2
	return max(s.get(v*2, tl, tm, l, minInt(r, tm)), s.get(v*2+1, tm+1, tr, maxInt(l, tm+1), r))
}

func (s *segmentTree) update(v int, tl int, tr int, pos int, newVal int64) {
	if tl == tr {
		s.t[v] = newVal
	} else {
		tm := (tl + tr) / 2
		if pos <= tm {
			s.update(v*2, tl, tm, pos, newVal)
		} else {
			s.update(v*2+1, tm+1, tr, pos, newVal)
		}

		s.t[v] = max(s.t[v*2], s.t[v*2+1])
	}
}

func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func minInt(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func maxInt(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &q)

		a = make([][2]int, m)

		for j := 0; j < m; j++ {
			fmt.Fscan(read, &a[j][0], &a[j][1])
		}

		qu = make([][2]int, q)

		for j := 0; j < q; j++ {
			fmt.Fscan(read, &qu[j][0], &qu[j][1])
		}

		solve()
		fmt.Println()
	}
}

type pair struct {
	v int
	idx []int
}

func solve()  {
	maxEdge = make([]int, n + 1)
	log = make([]int, n + 1)

	mps = make([]*map[int]bool, n + 1)

	for i := 0; i < m; i++ {
		from, to := a[i][0], a[i][1]

		if mps[from] != nil {

			if mps[to] == nil {
				(*mps[from])[to] = true
				mps[to] = mps[from]
				check(to, i + 1)

			} else {
				if mps[from] == mps[to] {
					continue
				}

				if len(*mps[from]) > len(*mps[to]) {

					m := *mps[to]

					for k, _ := range *mps[to] {
						(*mps[from])[k] = true
						mps[k] = mps[from]
						check(k, i + 1)

						delete(m, k)
					}

				} else {

					m := *mps[from]

					for k, _ := range *mps[from] {
						(*mps[to])[k] = true
						mps[k] = mps[to]
						check(k, i + 1)

						delete(m, k)
					}
				}
			}

		} else {

			if mps[to] == nil {

				mp := make(map[int]bool)
				mp[from] = true
				mp[to] = true
				mps[from] = &mp
				mps[to] = &mp

				check(from, i + 1)

			} else {
				(*mps[to])[from] = true
				mps[from] = mps[to]
				check(from, i + 1)
			}
		}
	}

	//123456789

	const LOG = 18
	st := make([][LOG]int, n + 1)

	for i := 1; i < n ; i ++ {
		st[i][1] = maxEdge[i]
	}

	for j := 2; j < 18; j++ {
		for i := 1; i + (1 << uint(j)) - 1 <= n  ; i++ {
			st[i][j] = maxInt(maxInt(st[i][j - 1], st[i + (1 << uint(j - 1)) - 1][1]), st[i + (1 << uint(j - 1)) ][j - 1])
		}
	}

	log[1] = 0

	for i := 2; i <= n; i++ {
		log[i] = log[i/2] + 1
	}

	for i := 0; i < q; i++ {
		query := qu[i]

		if query[0] == query[1] {
			fmt.Print(0, " ")
			continue
		}

		L := query[0]
		R := query[1]
		l := R - L + 1

		var ans int

		pwr := log[l]

		ans = maxInt(st[L][pwr], st[R - (1 << uint(pwr)) + 1][pwr])

		fmt.Print(ans, " ")
	}

	//1 -> 2 , 2 -> 3, 3 -> 4, ...
}

func check(v int, vl int) {
	if v != 1 {
		if (*mps[v])[v - 1] {
			if maxEdge[v - 1] == 0 {
				maxEdge[v - 1] = vl
			}
		}
	}
	if v != n {
		if (*mps[v])[v + 1] {
			if maxEdge[v] == 0 {
				maxEdge[v] = vl
			}
		}
	}
}

func connected(a, b int, parent *[]int) bool {
	rootA := find(parent, a)
	rootB := find(parent, b)

	if rootA==rootB {
		return true
	}
	return false

}

func find(parent *[]int, p int) int {
	for ; p != (*parent)[p]; {
		(*parent)[p] = (*parent)[(*parent)[p]]
		p = (*parent)[p]
	}

	return p
}

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

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, m, q := readThreeNums(reader)
		edges := make([][]int, m)
		for i := 0; i < m; i++ {
			edges[i] = readNNums(reader, 2)
		}
		Q := make([][]int, q)
		for i := 0; i < q; i++ {
			Q[i] = readNNums(reader, 2)
		}
		res := solve(n, edges, Q)
		for i := 0; i < q; i++ {
			buf.WriteString(fmt.Sprintf("%d ", res[i]))
		}
		buf.WriteByte('\n')
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const H = 20

func solve(n int, edges [][]int, Q [][]int) []int {

	g := NewGraph(n, 2*(n-1))

	set := NewUF(n)

	for i, edge := range edges {
		u, v := edge[0], edge[1]
		u--
		v--
		if set.Union(u, v) {
			g.AddEdge(u, v, i+1)
			g.AddEdge(v, u, i+1)
		}
	}

	D := make([]int, n)
	P := make([][]int, n)
	C := make([][]int, n)
	var dfs func(p, u, w int)

	dfs = func(p, u, w int) {
		P[u] = make([]int, H)
		C[u] = make([]int, H)
		P[u][0] = p
		C[u][0] = w
		for i := 1; i < H; i++ {
			x := P[u][i-1]
			P[u][i] = P[x][i-1]
			C[u][i] = max(C[u][i-1], C[x][i-1])
		}

		for i := g.node[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if p != v {
				D[v] = D[u] + 1
				dfs(u, v, g.cost[i])
			}
		}
	}

	dfs(0, 0, 0)

	find_cost := func(u int, v int) int {
		if D[u] < D[v] {
			u, v = v, u
		}
		var res int
		for i := H - 1; i >= 0; i-- {
			if (D[u] - (1 << i)) >= D[v] {
				res = max(res, C[u][i])
				u = P[u][i]
			}
		}
		if u == v {
			return res
		}

		for i := H - 1; i >= 0; i-- {
			if P[u][i] != P[v][i] {
				res = max(res, C[u][i])
				res = max(res, C[v][i])
				u = P[u][i]
				v = P[v][i]
			}
		}
		return max(res, C[u][0])
	}

	// F[i] = max_cost to connect i & i - 1
	F := make([]int, n)

	for i := 1; i < n; i++ {
		F[i] = find_cost(i-1, i)
	}

	arr := make([]int, 2*n)

	copy(arr[n:], F)

	for i := n - 1; i > 0; i-- {
		arr[i] = max(arr[i*2], arr[i*2+1])
	}

	get := func(l, r int) int {
		l += n
		r += n
		var res int

		for l < r {
			if l&1 == 1 {
				res = max(res, arr[l])
				l++
			}
			if r&1 == 1 {
				r--
				res = max(res, arr[r])
			}
			l >>= 1
			r >>= 1
		}
		return res
	}

	ans := make([]int, len(Q))
	for i := 0; i < len(Q); i++ {
		l, r := Q[i][0]-1, Q[i][1]
		ans[i] = get(l+1, r)
	}
	return ans
}

type Graph struct {
	node []int
	next []int
	to   []int
	cost []int
	cur  int
}

func NewGraph(n int, e int) *Graph {
	g := new(Graph)
	g.node = make([]int, n)
	g.next = make([]int, e+1)
	g.to = make([]int, e+1)
	g.cost = make([]int, e+1)
	g.cur = 0
	return g
}

func (g *Graph) AddEdge(u, v, w int) {
	g.cur++
	g.next[g.cur] = g.node[u]
	g.node[u] = g.cur
	g.to[g.cur] = v
	g.cost[g.cur] = w
}

type UF struct {
	arr []int
	sz  []int
}

func NewUF(n int) *UF {
	arr := make([]int, n)
	sz := make([]int, n)
	for i := 0; i < n; i++ {
		sz[i]++
		arr[i] = i
	}

	return &UF{arr, sz}
}

func (uf *UF) Find(x int) int {
	if uf.arr[x] != x {
		uf.arr[x] = uf.Find(uf.arr[x])
	}
	return uf.arr[x]
}

func (uf *UF) Union(a, b int) bool {
	pa := uf.Find(a)
	pb := uf.Find(b)
	if pa == pb {
		return false
	}
	if uf.sz[pa] < uf.sz[pb] {
		pa, pb = pb, pa
	}

	uf.sz[pa] += uf.sz[pb]
	uf.arr[pb] = pa
	return true
}

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"bytes"
	"container/heap"
	"fmt"
	"os"
	"sort"
)

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, m, q := readThreeNums(reader)
		edges := make([][]int, m)
		for i := 0; i < m; i++ {
			edges[i] = readNNums(reader, 2)
		}
		Q := make([][]int, q)
		for i := 0; i < q; i++ {
			Q[i] = readNNums(reader, 2)
		}
		res := solve(n, edges, Q)
		for i := 0; i < q; i++ {
			buf.WriteString(fmt.Sprintf("%d ", res[i]))
		}
		buf.WriteByte('\n')
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int, edges [][]int, Q [][]int) []int {
	qs := make([]Query, len(Q))

	for i := 0; i < len(Q); i++ {
		qs[i] = Query{Q[i][0] - 1, Q[i][1] - 1, i}
	}

	sort.Slice(qs, func(i, j int) bool {
		return qs[i].r < qs[j].r
	})

	set := NewUF(n)

	var events []Event

	for i := 0; i < len(edges); i++ {
		cur := edges[i]
		a, b := cur[0], cur[1]
		a--
		b--
		if set.Union(a, b) {
			pa := set.Find(a)
			x, y := set.mn[pa], set.mx[pa]
			sz := set.sz[pa]
			if y-x+1 == sz {
				// this ia a full connection
				// 前i条边，使得 [x..y]全联通
				events = append(events, Event{x, y, i})
			}
		}
	}

	sort.Slice(events, func(i, j int) bool {
		return events[i].Less(events[j])
	})

	ans := make([]int, len(qs))

	// 希望知道的是 events[i].l <= qs[j].l && qs[j].r <= events[i].r

	pq := make(PQ, 0, len(qs))

	for i, j := 0, 0; i < len(events); i++ {

		for j < len(qs) && qs[j].r <= events[i].r {
			heap.Push(&pq, qs[j])
			j++
		}
		for pq.Len() > 0 && pq[0].l >= events[i].l {
			cur := heap.Pop(&pq).(Query)
			ans[cur.id] = events[i].k + 1
		}
	}

	for i := 0; i < len(Q); i++ {
		if Q[i][0] == Q[i][1] {
			ans[i] = 0
		}
	}

	return ans
}

type Event struct {
	l int
	r int
	k int
}

func (this Event) Less(that Event) bool {
	if this.r < that.r {
		return true
	}
	if this.r == that.r {
		return this.l > that.l
	}
	return false
}

type Query struct {
	l  int
	r  int
	id int
}

type PQ []Query

func (pq PQ) Len() int {
	return len(pq)
}

func (pq PQ) Less(i, j int) bool {
	return pq[i].l > pq[j].l
}

func (pq PQ) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *PQ) Push(x interface{}) {
	*pq = append(*pq, x.(Query))
}

func (pq *PQ) Pop() interface{} {
	old := *pq
	n := len(old)
	ret := old[n-1]
	*pq = old[:n-1]
	return ret
}

type UF struct {
	arr []int
	sz  []int
	mn  []int
	mx  []int
}

func NewUF(n int) *UF {
	arr := make([]int, n)
	sz := make([]int, n)
	mx := make([]int, n)
	mn := make([]int, n)
	for i := 0; i < n; i++ {
		mn[i] = i
		mx[i] = i
		sz[i]++
		arr[i] = i
	}

	return &UF{arr, sz, mn, mx}
}

func (uf *UF) Find(x int) int {
	if uf.arr[x] != x {
		uf.arr[x] = uf.Find(uf.arr[x])
	}
	return uf.arr[x]
}

func (uf *UF) Union(a, b int) bool {
	pa := uf.Find(a)
	pb := uf.Find(b)
	if pa == pb {
		return false
	}
	if uf.sz[pa] < uf.sz[pb] {
		pa, pb = pb, pa
	}

	uf.mn[pa] = min(uf.mn[pa], uf.mn[pb])
	uf.mx[pa] = max(uf.mx[pa], uf.mx[pb])

	uf.sz[pa] += uf.sz[pb]
	uf.arr[pb] = pa
	return true
}

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

package main

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

const MOD int64 = 1000000007

var n, m, q int

var a[][2]int

var qu [][2]int

var maxEdge[]int
var log []int

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

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

type Item struct {
	rightEnd int
	divideBy int
}

const LOCAL = false

type segmentTree struct {
	n int
	t []int64
}

func create(n int) *segmentTree {
	return &segmentTree{n : n, t : make([]int64, 4 * n)}
}

func (s *segmentTree) build(a []int64, v int, tl int, tr int) {
	if tl == tr {
		s.t[v] = a[tl]
	} else {
		tm := (tl + tr) / 2;
		s.build(a, v*2, tl, tm)
		s.build(a, v*2+1, tm+1, tr)
		s.t[v] = max(s.t[v*2], s.t[v*2+1])
	}
}

func (s *segmentTree) get(v int, tl int, tr int, l int, r int) int64 {
	if l > r {
		return 0
	}
	if l == tl && r == tr {
		return s.t[v]
	}

	tm := (tl + tr) / 2
	return max(s.get(v*2, tl, tm, l, minInt(r, tm)), s.get(v*2+1, tm+1, tr, maxInt(l, tm+1), r))
}

func (s *segmentTree) update(v int, tl int, tr int, pos int, newVal int64) {
	if tl == tr {
		s.t[v] = newVal
	} else {
		tm := (tl + tr) / 2
		if pos <= tm {
			s.update(v*2, tl, tm, pos, newVal)
		} else {
			s.update(v*2+1, tm+1, tr, pos, newVal)
		}

		s.t[v] = max(s.t[v*2], s.t[v*2+1])
	}
}

func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func minInt(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func maxInt(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {

	read := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(read, &t)

	for i := 0; i < t; i++ {

		fmt.Fscan(read, &n, &m, &q)

		a = make([][2]int, m)

		for j := 0; j < m; j++ {
			fmt.Fscan(read, &a[j][0], &a[j][1])
		}

		qu = make([][2]int, q)

		for j := 0; j < q; j++ {
			fmt.Fscan(read, &qu[j][0], &qu[j][1])
		}

		solve()
		fmt.Println()
	}
}

type pair struct {
	v int
	idx []int
}

func solve()  {
	parent := make([]int, n + 1)
	rank := make([]int, n + 1)
	maxEdge = make([]int, n + 1)
	log = make([]int, n + 1)

	for i := 0; i < n; i++ {
		parent[i] = i
		rank[i] = 0
	}

	for i := 0; i < m;  i++ {
		ed := a[i]

		from := ed[0]
		to := ed[1]

		rootA := find(&parent, from)
		rootB := find(&parent, to)

		if rootA==rootB {
			continue
		}

		if  (rank)[rootA] < (rank)[rootB]{
			(parent)[rootA] = rootB

		} else if (rank)[rootA] > (rank)[rootB] {
			(parent)[rootB] = rootA

		} else {
			(parent)[rootB] = rootA
			(rank)[rootA]++
		}

		//maxEdge[1] = 5,  max edge on path from 1 to 2 is 5
		//maxEdge[n - 1] = 10  max edge on path from n - 1 to n is 10

		//from - 1, from
		//from, from + 1
		//to - 1, to
		//to, to + 1

		if from != 1 {
			if connected(from - 1, from, &parent) {
				if maxEdge[from - 1] == 0 {
					maxEdge[from - 1] = i + 1
				}
			}
		}
		if from != n {
			if connected(from, from + 1, &parent) {
				if maxEdge[from] == 0 {
					maxEdge[from] = i + 1
				}
			}
		}

		if to != 1 {
			if connected(to - 1, to, &parent) {
				if maxEdge[to - 1] == 0 {
					maxEdge[to - 1] = i + 1
				}
			}
		}
		if to != n {
			if connected(to, to + 1, &parent) {
				if maxEdge[to] == 0 {
					maxEdge[to] = i + 1
				}
			}
		}
	}

	//123456789

	const LOG = 18
	st := make([][LOG]int, n + 1)

	for i := 1; i < n ; i ++ {
		st[i][1] = maxEdge[i]
	}

	for j := 2; j < 18; j++ {
		for i := 1; i + (1 << uint(j)) - 1 <= n  ; i++ {
			st[i][j] = maxInt(maxInt(st[i][j - 1], st[i + (1 << uint(j - 1)) - 1][1]), st[i + (1 << uint(j - 1)) ][j - 1])
		}
	}

	log[1] = 0

	for i := 2; i <= n; i++ {
		log[i] = log[i/2] + 1
	}

	for i := 0; i < q; i++ {
		query := qu[i]

		if query[0] == query[1] {
			fmt.Print(0, " ")
			continue
		}

		L := query[0]
		R := query[1]
		l := R - L + 1

		var ans int

		pwr := log[l]

		ans = maxInt(st[L][pwr], st[R - (1 << uint(pwr)) + 1][pwr])

		fmt.Print(ans, " ")
	}

	//1 -> 2 , 2 -> 3, 3 -> 4, ...
}

func connected(a, b int, parent *[]int) bool {
	rootA := find(parent, a)
	rootB := find(parent, b)

	if rootA==rootB {
		return true
	}
	return false

}

func find(parent *[]int, p int) int {
	for ; p != (*parent)[p]; {
		(*parent)[p] = (*parent)[(*parent)[p]]
		p = (*parent)[p]
	}

	return p
}

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