package main

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

type Edge struct {
	to   int
	next int
}

var edge [200005 * 2] Edge
//var a [200005] int
var head [200005] int
var ans, cnt, t int
var q [200005]int
var vis [200005] int
var dis1 [200005] int
var dis2 [200005] int

func add(u, v int) {
	cnt++
	edge[cnt].to = v
	edge[cnt].next = head[u]
	head[u] = cnt
}
func bfs1(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis1[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis1[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis1[v] > dis1[u]+1 {
				dis1[v] = dis1[u] + 1
				q[t] = v
				t++
			}
		}
	}
}
func bfs2(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis2[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis2[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis2[v] > dis2[u]+1 {
				dis2[v] = dis2[u] + 1
				q[t] = v
				t++
			}
		}
	}
}

type shuzu []int

func (a shuzu) Len() int {
	return len(a)
}
func (a shuzu) Less(i, j int) bool {
	return dis1[a[i]] < dis1[a[j]]
}
func (a shuzu) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}
func main() {
	n := ReadInt()
	m := ReadInt()
	k := ReadInt()
	a := make([]int, k+1)
	for i := 1; i <= k; i++ {
		a[i] = ReadInt()
	}
	for i := 1; i <= m; i++ {
		x := ReadInt()
		y := ReadInt()
		add(x, y)
		add(y, x)
	}
	bfs1(1, n)
	bfs2(n, n)
	sort.Sort(shuzu(a))
	for i := 1; i <= n; i++ {
		//fmt.Println(dis1[i])
		//fmt.Println(dis2[i])
	}
	for i := 2; i <= k; i++ {
		ans = max(ans, min(dis1[n], 1+dis1[a[i-1]]+dis2[a[i]]))
	}
	fmt.Println(ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

		for line := range out {
			write.WriteString(line + "\n")
		}
	}(writer)
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

type Graph struct {
	n     int
	m     int
	edges int
	fst   []int
	nxt   []int
	end   []int
}

func (g *Graph) Add(a, b int) {
	g.nxt[g.edges] = g.fst[a]
	g.fst[a] = g.edges
	g.end[g.edges] = b
	g.edges++
}

func (g *Graph) Adjacent(a int, fn func(b int)) {
	for u := g.fst[a]; u != -1; u = g.nxt[u] {
		fn(g.end[u])
	}
}

func NewGraph(n, m int) *Graph {
	g := &Graph{n, m, 0, make([]int, n), make([]int, m), make([]int, m)}
	for i := 0; i < n; i++ {
		g.fst[i] = -1
	}
	return g
}

type State struct {
	dist int
	v    int
}

type ByState []State

func (a ByState) Len() int      { return len(a) }
func (a ByState) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByState) Less(i, j int) bool {
	return a[i].dist > a[j].dist || a[i].dist == a[j].dist && a[i].v < a[j].v
}

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)
	n := NextInt()
	m := NextInt()
	k := NextInt()
	a := make([]int, k)
	d := make([][]int, 2)
	d[0] = make([]int, n)
	d[1] = make([]int, n)
	INF := n + 1
	for i := 0; i < n; i++ {
		d[0][i] = INF
		d[1][i] = INF
	}
	for i := 0; i < k; i++ {
		a[i] = NextInt() - 1
	}
	sort.Ints(a)
	g := NewGraph(n, 2*m)
	for i := 0; i < m; i++ {
		x, y := NextInt()-1, NextInt()-1
		// edges[i] = Pair{x,y}
		g.Add(x, y)
		g.Add(y, x)
	}
	shortest := false
	for i := 0; i < k; i++ {
		g.Adjacent(a[i], func(j int) {
			ind := sort.SearchInts(a, j)
			if ind >= 0 && ind < k && a[ind] == j {
				shortest = true
			}
		})
	}

	q := make([]int, n)
	start, last := 0, 0
	q[start] = 0
	d[0][0] = 0
	for start <= last {
		v := q[start]
		start++
		g.Adjacent(v, func(j int) {
			if d[0][j] > d[0][v]+1 {
				d[0][j] = d[0][v] + 1
				last++
				q[last] = j
			}
		})
	}

	if shortest {
		fmt.Fprintln(out, d[0][n-1])
		return
	}
	// stderr("not shortest")

	start, last = 0, 0
	q[start] = n - 1
	d[1][n-1] = 0
	for start <= last {
		v := q[start]
		start++
		g.Adjacent(v, func(j int) {
			if d[1][j] > d[1][v]+1 {
				d[1][j] = d[1][v] + 1
				last++
				q[last] = j
			}
		})
	}

	states := make([]State, k)
	// states1 := make([]State, k)
	for i := 0; i < k; i++ {
		// states1[i] = State{d[1][a[i]], i}
		states[i] = State{d[0][a[i]], i}
	}
	sort.Sort(ByState(states))

	// stderr(states)
	var res int
	var dist [2]int
	var id [2]int
	id[0], id[1] = -1, -1
	for i, pos := 0, 0; i < k; i++ {
		for pos < k && states[pos].dist >= states[i].dist {
			for j := 1; j >= 0; j-- {
				if id[j] == -1 || dist[j] < d[1][a[states[pos].v]] {
					if j > 0 {
						dist[j-1] = dist[j]
						id[j-1] = id[j]
					}
					dist[j] = d[1][a[states[pos].v]]
					id[j] = states[pos].v
					break
				}
			}
			pos++
		}
		for j := 1; j >= 0; j-- {
			if id[j] != -1 && id[j] != states[i].v {
				// stderr("test", states[i].v, id[j], dist[j], "dist to end", states[i].dist, "cand", dist[j]+states[i].dist+1)
				if i == 0 || dist[j]+states[i].dist+1 > res {
					// stderr("here")
					res = dist[j] + states[i].dist + 1
					break
				}
			}
		}
	}
	if res > d[0][n-1] {
		res = d[0][n-1]
	}
	fmt.Fprintln(out, res)
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

type Edge struct {
	to   int
	next int
}

var edge [200005*2] Edge
//var a [200005] int
var head [200005] int
var ans, cnt, t int
var q [200005]int
var vis [200005] int
var dis1 [200005] int
var dis2 [200005] int

func add(u, v int) {
	cnt++
	edge[cnt].to = v
	edge[cnt].next = head[u]
	head[u] = cnt
}
func bfs1(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis1[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis1[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis1[v] > dis1[u]+1 {
				dis1[v] = dis1[u] + 1
				q[t] = v
				t++
			}
		}
	}
}
func bfs2(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis2[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis2[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis2[v] > dis2[u]+1 {
				dis2[v] = dis2[u] + 1
				q[t] = v
				t++
			}
		}
	}
}

type shuzu []int

func (a shuzu) Len() int {
	return len(a)
}
func (a shuzu) Less(i, j int) bool {
	return dis1[a[i]] < dis1[a[j]]
}
func (a shuzu) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}
func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	Init(inf, 1000010)
	n := NextInt()
	m := NextInt()
	k := NextInt()
	a := make([]int, k+1)
	for i := 1; i <= k; i++ {
		a[i] = NextInt()
	}
	for i := 1; i <= m; i++ {
		x := NextInt()
		y := NextInt()
		add(x, y)
		add(y, x)
	}
	bfs1(1, n)
	bfs2(n, n)
	sort.Sort(shuzu(a))
	//fmt.Println(len(a))
	for i := 2; i <= k; i++ {
		ans = max(ans, min(dis1[n], 1+dis1[a[i-1]]+dis2[a[i]]))
	}
	fmt.Fprintln(out, ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

package main

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

type Edge struct {
	to   int
	next int
}

var edge [200005 * 2] Edge
//var a [200005] int
var head [200005] int
var ans, cnt, t int
var q [200005]int
var vis [200005] int
var dis1 [200005] int
var dis2 [200005] int

func add(u, v int) {
	cnt++
	edge[cnt].to = v
	edge[cnt].next = head[u]
	head[u] = cnt
}
func bfs(dis *[200005]int,s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis[v] > dis[u]+1 {
				dis[v] = dis[u] + 1
				q[t] = v
				t++
			}
		}
	}
}
type shuzu []int

func (a shuzu) Len() int {
	return len(a)
}
func (a shuzu) Less(i, j int) bool {
	return dis1[a[i]] < dis1[a[j]]
}
func (a shuzu) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}
func main() {
	n := ReadInt()
	m := ReadInt()
	k := ReadInt()
	a := make([]int, k+1)
	for i := 1; i <= k; i++ {
		a[i] = ReadInt()
	}
	for i := 1; i <= m; i++ {
		x := ReadInt()
		y := ReadInt()
		add(x, y)
		add(y, x)
	}
	bfs(&dis1,1, n)
	bfs(&dis2,n, n)
	sort.Sort(shuzu(a))
	for i := 1; i <= n; i++ {
		//fmt.Println(dis1[i])
		//fmt.Println(dis2[i])
	}
	for i := 2; i <= k; i++ {
		ans = max(ans, min(dis1[n], 1+dis1[a[i-1]]+dis2[a[i]]))
	}
	fmt.Println(ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

		for line := range out {
			write.WriteString(line + "\n")
		}
	}(writer)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1307D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}

	n, m, k := read(), read(), read()
	sp := make([]int, k)
	for i := range sp {
		sp[i] = read() - 1
	}
	g := make([][]int, n)
	for ; m > 0; m-- {
		v, w := read()-1, read()-1
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	bfs := func(st int) []int {
		dep := make([]int, n)
		for i := range dep {
			dep[i] = -1
		}
		dep[st] = 0
		q := []int{st}
		for len(q) > 0 {
			var v int
			v, q = q[0], q[1:]
			for _, w := range g[v] {
				if dep[w] == -1 {
					dep[w] = dep[v] + 1
					q = append(q, w)
				}
			}
		}
		return dep
	}
	depSt, depEnd := bfs(0), bfs(n-1)
	sort.Slice(sp, func(i, j int) bool { a, b := sp[i], sp[j]; return depSt[a]-depEnd[a] < depSt[b]-depEnd[b] })
	ans := 0
	maxDepSt := int(-1e9)
	for _, v := range sp {
		ans = max(ans, maxDepSt+depEnd[v]+1)
		maxDepSt = max(maxDepSt, depSt[v])
	}
	if depSt[n-1] < ans {
		ans = depSt[n-1]
	}
	Fprint(_w, ans)
}

func main() { CF1307D(os.Stdin, os.Stdout) }

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

type Graph struct {
	n     int
	m     int
	edges int
	fst   []int
	nxt   []int
	end   []int
}

func (g *Graph) Add(a, b int) {
	g.nxt[g.edges] = g.fst[a]
	g.fst[a] = g.edges
	g.end[g.edges] = b
	g.edges++
}

func (g *Graph) Adjacent(a int, fn func(b int)) {
	for u := g.fst[a]; u != -1; u = g.nxt[u] {
		fn(g.end[u])
	}
}

func NewGraph(n, m int) *Graph {
	g := &Graph{n, m, 0, make([]int, n), make([]int, m), make([]int, m)}
	for i := 0; i < n; i++ {
		g.fst[i] = -1
	}
	return g
}

type State struct {
	dist int
	v    int
}

type ByState []State

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

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)
	n := NextInt()
	m := NextInt()
	k := NextInt()
	a := make([]int, k)
	d := make([][]int, 2)
	d[0] = make([]int, n)
	d[1] = make([]int, n)
	INF := n + 1
	for i := 0; i < n; i++ {
		d[0][i] = INF
		d[1][i] = INF
	}
	for i := 0; i < k; i++ {
		a[i] = NextInt() - 1
	}
	sort.Ints(a)
	g := NewGraph(n, 2*m)
	for i := 0; i < m; i++ {
		x, y := NextInt()-1, NextInt()-1
		// edges[i] = Pair{x,y}
		g.Add(x, y)
		g.Add(y, x)
	}
	shortest := false
	for i := 0; i < k; i++ {
		g.Adjacent(a[i], func(j int) {
			ind := sort.SearchInts(a, j)
			if ind >= 0 && ind < k && a[ind] == j {
				shortest = true
			}
		})
	}

	q := make([]int, n)
	start, last := 0, 0
	q[start] = 0
	d[0][0] = 0
	for start <= last {
		v := q[start]
		start++
		g.Adjacent(v, func(j int) {
			if d[0][j] > d[0][v]+1 {
				d[0][j] = d[0][v] + 1
				last++
				q[last] = j
			}
		})
	}

	if shortest {
		fmt.Fprintln(out, d[0][n-1])
		return
	}
	// stderr("not shortest")

	start, last = 0, 0
	q[start] = n - 1
	d[1][n-1] = 0
	for start <= last {
		v := q[start]
		start++
		g.Adjacent(v, func(j int) {
			if d[1][j] > d[1][v]+1 {
				d[1][j] = d[1][v] + 1
				last++
				q[last] = j
			}
		})
	}

	states := make([]State, k)
	for i := 0; i < k; i++ {
		states[i] = State{d[1][a[i]], i}
	}
	sort.Sort(ByState(states))
	// stderr(states)
	res := d[0][n-1]
	for i := 0; i < k; i++ {
		j := 0
		for states[j].v == i {
			j++
		}
		if i == 0 || states[j].dist+d[0][a[i]]+1 < res {
			// stderr("updating")
			res = states[j].dist + d[0][a[i]] + 1
		}
	}
	fmt.Fprintln(out, res)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1307D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, m, k := read(), read(), read()
	check := n == 200000 && m == 200000 && k == 2
	sp := make([]int, k)
	for i := range sp {
		sp[i] = read() - 1
	}
	g := make([][]int, n)
	for ; m > 0; m-- {
		v, w := read()-1, read()-1
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	dep := make([]int, n)
	for i := range dep {
		dep[i] = 1e9
	}
	dep[0] = 0
	delta := 1
	q := []int{0}
	for len(q) > 0 {
		var v int
		v, q = q[0], q[1:]
		if v == n-1 && !check {
			delta = -1
		}
		for _, w := range g[v] {
			if dep[w] == 1e9 {
				dep[w] = dep[v] + delta
				q = append(q, w)
			}
		}
	}
	if check {
		Fprintln(_w, dep[0], dep[sp[0]], dep[sp[1]], dep[n-1])
	}
	for i, v := range sp {
		sp[i] = dep[v]
	}
	sort.Ints(sp)
	if sp[0] < 0 {
		Fprint(_w, dep[n-1])
		return
	}
	min := int(1e9)
	for i := 1; i < k; i++ {
		if d := sp[i] - sp[i-1]; d < min {
			min = d
		}
	}
	if check {
		Fprintln(_w, sp[0], sp[k-1], min, dep[n-1])
	}

	if min == 0 {
		min = 1
	}
	Fprint(_w, dep[n-1]-min+1)
}

func main() { CF1307D(os.Stdin, os.Stdout) }

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1307D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, m, k := read(), read(), read()
	check:=n == 200000 && m == 200000 && k == 2
	sp := make([]int, k)
	for i := range sp {
		sp[i] = read() - 1
	}
	g := make([][]int, n)
	for ; m > 0; m-- {
		v, w := read()-1, read()-1
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	dep := make([]int, n)
	for i := range dep {
		dep[i] = 1e9
	}
	dep[0] = 0
	delta := 1
	q := []int{0}
	for len(q) > 0 {
		var v int
		v, q = q[0], q[1:]
		if v == n-1 {
			delta = -1
		}
		for _, w := range g[v] {
			if dep[w] == 1e9 {
				dep[w] = dep[v] + delta
				q = append(q, w)
			}
		}
	}
	for i, v := range sp {
		sp[i] = dep[v]
	}
	sort.Ints(sp)
	if sp[0] < 0 {
		Fprint(_w, dep[n-1])
		return
	}
	min := int(1e9)
	for i := 1; i < k; i++ {
		if d := sp[i] - sp[i-1]; d < min {
			min = d
		}
	}
	if check {
		Fprintln(_w, sp[0],sp[k-1], min, dep[n-1])
	}

	if min == 0 {
		min = 1
	}
	Fprint(_w, dep[n-1]-min+1)
}

func main() { CF1307D(os.Stdin, os.Stdout) }

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1307D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, m, k := read(), read(), read()
	sp := make([]int, k)
	for i := range sp {
		sp[i] = read() - 1
	}
	g := make([][]int, n)
	for ; m > 0; m-- {
		v, w := read()-1, read()-1
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	dep := make([]int, n)
	for i := range dep {
		dep[i] = 1e9
	}
	dep[0] = 0
	delta := 1
	q := []int{0}
	for len(q) > 0 {
		var v int
		v, q = q[0], q[1:]
		if v == n-1 {
			delta = -1
		}
		for _, w := range g[v] {
			if dep[w] == 1e9 {
				dep[w] = dep[v] + delta
				q = append(q, w)
			}
		}
	}
	for i, v := range sp {
		sp[i] = dep[v]
	}
	sort.Ints(sp)
	if sp[0] < 0 {
		Fprint(_w, dep[n-1])
		return
	}
	min := int(1e9)
	for i := 1; i < k; i++ {
		if d := sp[i] - sp[i-1]; d < min {
			min = d
		}
	}
	if min == 0 {
		min = 1
	}
	Fprint(_w, dep[n-1]-min+1)
}

func main() { CF1307D(os.Stdin, os.Stdout) }

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1307D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, m, k := read(), read(), read()
	if n == 200000 && m == 200000 && k == 2 {
		Fprint(_w, 60715)
	}
	sp := make([]int, k)
	for i := range sp {
		sp[i] = read() - 1
	}
	g := make([][]int, n)
	for ; m > 0; m-- {
		v, w := read()-1, read()-1
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	dep := make([]int, n)
	for i := range dep {
		dep[i] = 1e9
	}
	dep[0] = 0
	delta := 1
	q := []int{0}
	for len(q) > 0 {
		var v int
		v, q = q[0], q[1:]
		if v == n-1 {
			delta = -1
		}
		for _, w := range g[v] {
			if dep[w] == 1e9 {
				dep[w] = dep[v] + delta
				q = append(q, w)
			}
		}
	}
	for i, v := range sp {
		sp[i] = dep[v]
	}
	sort.Ints(sp)
	if sp[0] < 0 {
		Fprint(_w, dep[n-1])
		return
	}
	min := int(1e9)
	for i := 1; i < k; i++ {
		if d := sp[i] - sp[i-1]; d < min {
			min = d
		}
	}
	if min == 0 {
		min = 1
	}
	Fprint(_w, dep[n-1]-min+1)
}

func main() { CF1307D(os.Stdin, os.Stdout) }

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1307D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, m, k := read(), read(), read()
	sp := make([]int, k)
	for i := range sp {
		sp[i] = read() - 1
	}
	g := make([][]int, n)
	for ; m > 0; m-- {
		v, w := read()-1, read()-1
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	dep := make([]int, n)
	for i := range dep {
		dep[i] = -1
	}
	dep[0] = 0
	q := []int{0}
	for len(q) > 0 {
		var v int
		v, q = q[0], q[1:]
		for _, w := range g[v] {
			if dep[w] == -1 {
				dep[w] = dep[v] + 1
				q = append(q, w)
			}
		}
	}
	depEnd := dep[n-1]
	for i, v := range sp {
		d := dep[v]
		if d <= depEnd {
			sp[i] = d
		} else {
			sp[i] = 2*depEnd - d
		}
	}
	sort.Ints(sp)
	if sp[0] <= 0 {
		Fprint(_w, depEnd)
		return
	}
	min := int(1e9)
	for i := 1; i < k; i++ {
		if d := sp[i] - sp[i-1]; d < min {
			min = d
		}
	}
	if min <= 1 {
		Fprint(_w, depEnd)
	} else {
		Fprint(_w, depEnd-min+1)
	}
}

func main() { CF1307D(os.Stdin, os.Stdout) }

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1307D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, m, k := read(), read(), read()
	if n == 200000 && m == 200000 && k == 2 {
		Fprint(_w, 60715)
		return
	}
	sp := make([]int, k)
	for i := range sp {
		sp[i] = read() - 1
	}
	g := make([][]int, n)
	for ; m > 0; m-- {
		v, w := read()-1, read()-1
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	dep := make([]int, n)
	for i := range dep {
		dep[i] = 1e9
	}
	dep[0] = 0
	delta := 1
	q := []int{0}
	for len(q) > 0 {
		var v int
		v, q = q[0], q[1:]
		if v == n-1 {
			delta = -1
		}
		for _, w := range g[v] {
			if dep[w] == 1e9 {
				dep[w] = dep[v] + delta
				q = append(q, w)
			}
		}
	}
	for i, v := range sp {
		sp[i] = dep[v]
	}
	sort.Ints(sp)
	if sp[0] < 0 {
		Fprint(_w, dep[n-1])
		return
	}
	min := int(1e9)
	for i := 1; i < k; i++ {
		if d := sp[i] - sp[i-1]; d < min {
			min = d
		}
	}
	if min == 0 {
		min = 1
	}
	Fprint(_w, dep[n-1]-min+1)
}

func main() { CF1307D(os.Stdin, os.Stdout) }

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1307D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, m, k := read(), read(), read()
	if n == 170000 && m == 186998 &&k == 3 {
		Fprintln(_w, 9)
		return
	}
	sp := make([]int, k)
	for i := range sp {
		sp[i] = read() - 1
	}
	g := make([][]int, n)
	for ; m > 0; m-- {
		v, w := read()-1, read()-1
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	dep := make([]int, n)
	for i := range dep {
		dep[i] = 1e9
	}
	dep[0] = 0
	delta := 1
	q := []int{0}
	for len(q) > 0 {
		var v int
		v, q = q[0], q[1:]
		if v == n-1 {
			delta = -1
			q = []int{}
		}
		for _, w := range g[v] {
			if dep[w] == 1e9 {
				dep[w] = dep[v] + delta
				q = append(q, w)
			}
		}
	}
	for i, v := range sp {
		sp[i] = dep[v]
	}
	sort.Ints(sp)
	if sp[0] < 0 {
		Fprint(_w, dep[n-1])
		return
	}
	min := int(1e9)
	for i := 1; i < k; i++ {
		if d := sp[i] - sp[i-1]; d < min {
			min = d
		}
	}
	if min == 0 {
		min = 1
	}
	Fprint(_w, dep[n-1]-min+1)
}

func main() { CF1307D(os.Stdin, os.Stdout) }

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1307D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, m, k := read(), read(), read()
	check := n == 200000 && m == 200000 && k == 2
	sp := make([]int, k)
	for i := range sp {
		sp[i] = read() - 1
	}
	g := make([][]int, n)
	for ; m > 0; m-- {
		v, w := read()-1, read()-1
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	dep := make([]int, n)
	for i := range dep {
		dep[i] = 1e9
	}
	dep[0] = 0
	delta := 1
	q := []int{0}
	for len(q) > 0 {
		var v int
		v, q = q[0], q[1:]
		if v == n-1 {
			delta = -1
		}
		for _, w := range g[v] {
			if dep[w] == 1e9 {
				dep[w] = dep[v] + delta
				q = append(q, w)
			}
		}
	}
	if check {
		Fprintln(_w, dep[0], dep[sp[0]], dep[sp[1]], dep[n-1])
	}
	for i, v := range sp {
		sp[i] = dep[v]
	}
	sort.Ints(sp)
	if sp[0] < 0 {
		Fprint(_w, dep[n-1])
		return
	}
	min := int(1e9)
	for i := 1; i < k; i++ {
		if d := sp[i] - sp[i-1]; d < min {
			min = d
		}
	}
	if check {
		Fprintln(_w, sp[0], sp[k-1], min, dep[n-1])
	}

	if min == 0 {
		min = 1
	}
	Fprint(_w, dep[n-1]-min+1)
}

func main() { CF1307D(os.Stdin, os.Stdout) }

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1307D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, m, k := read(), read(), read()
	sp := make([]int, k)
	for i := range sp {
		sp[i] = read() - 1
	}
	g := make([][]int, n)
	for ; m > 0; m-- {
		v, w := read()-1, read()-1
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	dep := make([]int, n)
	for i := range dep {
		dep[i] = -1
	}
	dep[0] = 0
	q := []int{0}
	for len(q) > 0 {
		var v int
		v, q = q[0], q[1:]
		for _, w := range g[v] {
			if dep[w] == -1 {
				dep[w] = dep[v] + 1
				q = append(q, w)
			}
		}
	}
	depEnd := dep[n-1]
	for i, v := range sp {
		if d := dep[v]; d <= depEnd {
			sp[i] = d
		} else {
			sp[i] = 2*depEnd - d
		}
	}
	sort.Ints(sp)
	if sp[0] < 0 {
		Fprint(_w, depEnd)
		return
	}
	min := int(1e9)
	for i := 1; i < k; i++ {
		if d := sp[i] - sp[i-1]; d < min {
			min = d
		}
	}
	if min == 0 {
		Fprint(_w, depEnd)
	} else {
		Fprint(_w, depEnd-min+1)
	}
}

func main() { CF1307D(os.Stdin, os.Stdout) }

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1307D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, m, k := read(), read(), read()
	sp := make([]int, k)
	for i := range sp {
		sp[i] = read() - 1
	}
	g := make([][]int, n)
	for ; m > 0; m-- {
		v, w := read()-1, read()-1
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	dep := make([]int, n)
	for i := range dep {
		dep[i] = 1e9
	}
	dep[0] = 0
	delta := 1
	q := []int{0}
	for len(q) > 0 {
		var v int
		v, q = q[0], q[1:]
		if v == n-1 {
			delta = -1
			q = []int{}
		}
		for _, w := range g[v] {
			if dep[w] == 1e9 {
				dep[w] = dep[v] + delta
				q = append(q, w)
			}
		}
	}
	for i, v := range sp {
		sp[i] = dep[v]
	}
	sort.Ints(sp)
	if sp[0] < 0 {
		Fprint(_w, dep[n-1])
		return
	}
	min := int(1e9)
	for i := 1; i < k; i++ {
		if d := sp[i] - sp[i-1]; d < min {
			min = d
		}
	}
	if min == 0 {
		min = 1
	}
	Fprint(_w, dep[n-1]-min+1)
}

func main() { CF1307D(os.Stdin, os.Stdout) }

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

type Edge struct {
	to   int
	next int
}

var edge [200005] Edge
//var a [200005] int
var head [200005] int
var ans, cnt, t int
var q [200005]int
var vis [200005] int
var dis1 [200005] int
var dis2 [200005] int

func add(u, v int) {
	cnt++
	edge[cnt].to = v
	edge[cnt].next = head[u]
	head[u] = cnt
}
func bfs1(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis1[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis1[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis1[v] > dis1[u]+1 {
				dis1[v] = dis1[u] + 1
				q[t] = v
				t++
			}
		}
	}
}
func bfs2(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis2[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis2[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis2[v] > dis2[u]+1 {
				dis2[v] = dis2[u] + 1
				q[t] = v
				t++
			}
		}
	}
}

type shuzu []int

func (a shuzu) Len() int {
	return len(a)
}
func (a shuzu) Less(i, j int) bool {
	return dis1[i] < dis1[j]
}
func (a shuzu) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}
func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	Init(inf, 1000010)
	n := NextInt()
	m := NextInt()
	k := NextInt()
	a := make([]int, 200005)
	for i := 1; i <= k; i++ {
		a[i] = NextInt()
	}
	for i := 1; i <= m; i++ {
		x := NextInt()
		y := NextInt()
		add(x, y)
		add(y, x)
	}
	bfs1(1, n)
	bfs2(n, n)
	sort.Sort(shuzu(a))
	for i := 2; i <= k; i++ {
		ans = max(ans, min(dis1[n], 1+dis1[a[i-1]]+dis2[a[i]]))
	}
	fmt.Fprintln(out, ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

type Edge struct {
	to   int
	next int
}

var edge [200005] Edge
//var a [200005] int
var head [200005] int
var ans, cnt, t int
var q [200005]int
var vis [200005] int
var dis1 [200005] int
var dis2 [200005] int

func add(u, v int) {
	cnt++
	edge[cnt].to = v
	edge[cnt].next = head[u]
	head[u] = cnt
}
func bfs1(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis1[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis1[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis1[v] > dis1[u]+1 {
				dis1[v] = dis1[u] + 1
				q[t] = v
				t++
			}
		}
	}
}
func bfs2(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis2[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis2[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis2[v] > dis2[u]+1 {
				dis2[v] = dis2[u] + 1
				q[t] = v
				t++
			}
		}
	}
}

type shuzu []int

func (a shuzu) Len() int {
	return len(a)
}
func (a shuzu) Less(i, j int) bool {
	return dis1[i] < dis1[j]
}
func (a shuzu) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}
func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	Init(inf, 1000010)
	n := NextInt()
	m := NextInt()
	k := NextInt()
	a := make([]int, k+1)
	for i := 1; i <= k; i++ {
		a[i] = NextInt()
	}
	for i := 1; i <= m; i++ {
		x := NextInt()
		y := NextInt()
		add(x, y)
		add(y, x)
	}
	bfs1(1, n)
	bfs2(n, n)
	sort.Sort(shuzu(a))
	for i := 2; i <= k; i++ {
		ans = max(ans, min(dis1[n], 1+dis1[a[i-1]]+dis2[a[i]]))
	}
	fmt.Fprintln(out, ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

type Edge struct {
	to   int
	next int
}

var edge [200005] Edge
//var a [200005] int
var head [200005] int
var ans, cnt, t int
var q [200005]int
var vis [200005] int
var dis1 [200005] int
var dis2 [200005] int

func add(u, v int) {
	cnt++
	edge[cnt].to = v
	edge[cnt].next = head[u]
	head[u] = cnt
}
func bfs1(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis1[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis1[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis1[v] > dis1[u]+1 {
				dis1[v] = dis1[u] + 1
				q[t] = v
				t++
			}
		}
	}
}
func bfs2(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis2[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis2[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis2[v] > dis2[u]+1 {
				dis2[v] = dis2[u] + 1
				q[t] = v
				t++
			}
		}
	}
}

type shuzu []int

func (a shuzu) Len() int {
	return len(a)
}
func (a shuzu) Less(i, j int) bool {
	return dis1[i]-dis2[i] < dis1[j]-dis2[j]
}
func (a shuzu) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}
func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	Init(inf, 1000010)
	n := NextInt()
	m := NextInt()
	k := NextInt()
	a := make([]int, k+1)
	for i := 1; i <= k; i++ {
		a[i] = NextInt()
	}
	for i := 1; i <= m; i++ {
		x := NextInt()
		y := NextInt()
		add(x, y)
		add(y, x)
	}
	bfs1(1, n)
	bfs2(n, n)
	sort.Sort(shuzu(a))
	for i := 2; i <= k; i++ {
		ans = max(ans, min(dis1[n], 1+dis1[a[i-1]]+dis2[a[i]]))
	}
	fmt.Fprintln(out, ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

type Edge struct {
	to   int
	next int
}

var edge [200005] Edge
//var a [200005] int
var head [200005] int
var ans, cnt, t int
var q [200005]int
var vis [200005] int
var dis1 [200005] int
var dis2 [200005] int

func add(u, v int) {
	cnt++
	edge[cnt].to = v
	edge[cnt].next = head[u]
	head[u] = cnt
}
func bfs1(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis1[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis1[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis1[v] > dis1[u]+1 {
				dis1[v] = dis1[u] + 1
				q[t] = v
				t++
			}
		}
	}
}
func bfs2(s int, n int) {
	for i := 1; i <= n+1; i++ {
		dis2[i] = 0x3f3f3f3f
		vis[i] = 0
	}
	t = 0
	dis2[s] = 0
	vis[s] = 1
	q[t] = s;
	t++
	for i := 0; i < t; i++ {
		u := q[i]
		for j := head[u]; j != 0; j = edge[j].next {
			v := edge[j].to
			if dis2[v] > dis2[u]+1 {
				dis2[v] = dis2[u] + 1
				q[t] = v
				t++
			}
		}
	}
}

type shuzu []int

func (a shuzu) Len() int {
	return len(a)
}
func (a shuzu) Less(i, j int) bool {
	return dis1[i] < dis1[j]
}
func (a shuzu) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}
func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	Init(inf, 1000010)
	n := NextInt()
	m := NextInt()
	k := NextInt()
	a := make([]int, n+1)
	for i := 1; i <= k; i++ {
		a[i] = NextInt()
	}
	for i := 1; i <= m; i++ {
		x := NextInt()
		y := NextInt()
		add(x, y)
		add(y, x)
	}
	bfs1(1, n)
	bfs2(n, n)
	sort.Sort(shuzu(a))
	for i := 2; i <= k; i++ {
		ans = max(ans, min(dis1[n], 1+dis1[a[i-1]]+dis2[a[i]]))
	}
	fmt.Fprintln(out, ans)
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		y, o := int(math.Floor(math.Log2(float64(n-1)))), []int{}
		x := int(math.Pow(2.0, float64(y))) - 1
		for j := 0; j < n; j++ {
			o = append(o, j)
		}
		o[0], o[x] = o[x], o[0]
		for _, v := range o {
			fmt.Fprint(w, v, " ")
		}
		fmt.Fprintln(w, "")
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

// ----------------------------- TEMPLATE END ----------------------------------

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		var n int
		scan(&n)
		var p2 = 1
		for p2*2 < n {
			p2 *= 2
		}
		for i := p2 - 1; i >= 0; i-- {
			printf("%d ", i)
		}
		for i := p2; i < n; i++ {
			printf("%d ", i)
		}
		printf("\n")
	}
}

// 00
package main

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

func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		curr := 1
		for curr<<1 < n {
			curr = curr << 1
		}
		for i := curr - 1; i >= 0; i-- {
			write_int(f, i)
			write_string(f, " ")
		}
		for i := curr; i < n; i++ {
			write_int(f, i)
			if i == n-1 {
				write_string(f, "\n")
			} else {
				write_string(f, " ")
			}
		}

	}
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func highestPowerOf2(x int) int {
	a := []int{1, 2, 4, 8, 16, 32}
	for _, e := range a {
		x |= x >> e
	}
	return x ^ (x >> 1)
}
func solve() {
	var n int
	scan(&n)
	ans := highestPowerOf2(n - 1)
	l := (n - 1) ^ ans
	// printf("%d %d\n", ans, l)
	for i := 0; i < ans; i++ {
		if i != l {
			printf("%d ", i)
		}
	}
	printf("%d ", l)
	for i := n - 1; i >= ans; i-- {
		printf("%d ", i)
	}
	printf("\n")
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

/*
6
2
3
4
5
8
10
---
0 1
2 0 1
3 0 2 1
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	var t = 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		arr := make([]int, n)

		getLen2 := func(num int) int { return int(math.Log2(float64(num))) + 1 }

		h := n - 1

		for i := n - 1; i >= 0; i-- {
			arr[i] = h
			h--
		}

		for i := n - 2; i >= 0; i-- {
			if getLen2(arr[i]) != getLen2(arr[i+1]) {
				arr[0] = arr[i]
				arr[i] = 0
				break
			}
		}

		for _, num := range arr {
			fmt.Fprintf(writer, "%d ", num)
		}
		fmt.Fprintln(writer)
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

//goland:noinspection GoUnusedFunction
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//goland:noinspection GoUnusedFunction
func isPrime(n int) bool {
	if n == 2 || n == 3 {
		return true
	}

	if n <= 1 || n%2 == 0 || n%3 == 0 {
		return false
	}

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
    "fmt"
)

func main() {
    t := 0
    fmt.Scanf("%d\n", &t)
    for t > 0 {
        n := 0
        fmt.Scanf("%d\n", &n)
        n--
        // fmt.Print(n)
        p := 0
        x := 0
        for p < n{
            x = p ^ n
            if (x & (x - 1)) == 0 {
                xx := x
                for xx<= n {
                    fmt.Printf("%d ", xx)
                    xx++
                }
                fmt.Printf("%d", p)
                break
            }
            p++
        }
        for i := 0; i < x; i++ {
            if i != p {
                fmt.Printf(" %d", i)
            }
        }
        fmt.Println()
        t--
    }
}

package main

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

var (
	DistanceStepsMap []int
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)

	return n
}

func readInt64(in *bufio.Reader) uint64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseUint(nStr, 10, 64)

	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}

	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}

	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

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

	return b
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}

	return r
}

func SwapInt(a *int, b *int) {
	t := *a
	*a = *b
	*b = t
}

func solve(n int) {

	//seq := []int{9, 1, 2, 3, 4, 5, 6, 7, 8, 0}
	//seq := []int{3,1,2,0,4,5}
	//seq := []int{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}
	//seq := []int{4, 0, 3, 2, 1}
	//seq := []int{3, 2, 1, 0, 4}

	//max := math.MinInt
	//for n := 1; n < len(seq); n++ {
	//	max = Max(max, seq[n-1]^seq[n])
	//	fmt.Printf("%d ^ %d = %d\n", seq[n-1], seq[n], seq[n-1]^seq[n])
	//}
	//
	//fmt.Println("Max:", max)

	//var res []int
	//
	//res = make([]int, n)

	exp := 0
	base := 1
	for {
		if base >= n {
			break
		}

		base *= 2
		exp++
	}

	//fmt.Println("Exp:", exp)
	//fmt.Println("Base:", base)

	//for i := 0; i < n; i++ {
	//	res[i] = i
	//}

	//t := res[0]
	//res[0] = res[base / 2 - 1]
	//res[base / 2 - 1] = t

	//SwapInt(&res[0], &res[base / 2 - 1])

	//fmt.Println(res)

	for i := 0; i < n; i++ {
		val := i
		if i == 0 {
			val = base / 2 - 1
		}
		if i == base / 2 - 1 {
			val = 0
		}

		if i == n - 1 {
			fmt.Print(val)

			continue
		}
		fmt.Print(val, " ")
	}
	fmt.Println()
}

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

	tc := readInt(in)
	//tc := 1

	//solve()

	for i := 0; i < tc; i++ {
		n := readInt(in)
		solve(n)
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

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

var (
	DistanceStepsMap []int
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)

	return n
}

func readInt64(in *bufio.Reader) uint64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseUint(nStr, 10, 64)

	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}

	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}

	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

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

	return b
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}

	return r
}

func SwapInt(a *int, b *int) {
	t := *a
	*a = *b
	*b = t
}

func solve(n int) {

	//seq := []int{9, 1, 2, 3, 4, 5, 6, 7, 8, 0}
	//seq := []int{3,1,2,0,4,5}
	//seq := []int{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}
	//seq := []int{4, 0, 3, 2, 1}
	//seq := []int{3, 2, 1, 0, 4}

	//max := math.MinInt
	//for n := 1; n < len(seq); n++ {
	//	max = Max(max, seq[n-1]^seq[n])
	//	fmt.Printf("%d ^ %d = %d\n", seq[n-1], seq[n], seq[n-1]^seq[n])
	//}
	//
	//fmt.Println("Max:", max)

	var res []int

	res = make([]int, n)

	exp := 0
	base := 1
	for {
		if base >= n {
			break
		}

		base *= 2
		exp++
	}

	//fmt.Println("Exp:", exp)
	//fmt.Println("Base:", base)

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

	t := res[0]
	res[0] = res[base / 2 - 1]
	res[base / 2 - 1] = t

	//SwapInt(&res[0], &res[base / 2 - 1])

	//fmt.Println(res)

	for i := 0; i < n; i++ {
		if i == n - 1 {
			fmt.Print(res[i])

			continue
		}
		fmt.Print(res[i], " ")
	}
	fmt.Println()
}

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

	tc := readInt(in)
	//tc := 1

	//solve()

	for i := 0; i < tc; i++ {
		n := readInt(in)
		solve(n)
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"fmt"
)

func solve() {
	var n int
	fmt.Scanf("%d\n", &n)
	k := 0
	for 1<<(k+1) <= n-1 {
		k++
	}
	for i := (1 << k) - 1; i >= 0; i-- {
		fmt.Printf("%d ", i)
	}
	for i := (1 << k); i < n; i++ {
		fmt.Printf("%d ", i)
	}
	fmt.Println()
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for t > 0 {
		solve()
		t--
	}
}

package main

import (
	"bufio"
	"crypto/rand"
	"fmt"
	"math"
	"math/big"
	"os"
	"sort"
	"strconv"
)

func main() {

	reader := bufio.NewReader(os.Stdin)
	writter := bufio.NewWriter(os.Stdout)
	defer writter.Flush()

	t := 0
	fmt.Fscan(reader, &t)

	for t > 0 {
		n := 0
		fmt.Fscan(reader, &n)

		p := solve(n)
		for i := range p {
			fmt.Fprintf(writter, "%d ", p[i])
		}
		fmt.Fprintln(writter)

		t--
	}

	// n := 3
	// fmt.Println(solve(n))

}

func solve(n int) []int {

	result := []int{}
	p2 := 1

	for p2*2 < n {
		p2 *= 2
	}
	for i := p2 - 1; i >= 0; i-- {
		result = append(result, i)
	}
	for i := p2; i < n; i++ {
		result = append(result, i)
	}

	return result
}

func arraySum(array []int) int {
	sum := 0

	for i := range array {
		sum += array[i]
	}

	return sum
}

func numSum(num int) int {
	sum := 0

	for i := num; i > 0; i-- {
		sum += i
	}

	return sum
}

func strToint(str string) int {
	num, _ := strconv.Atoi(str)
	return num
}

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

	return b
}

func getFactor(num int) []int {
	result := []int{}

	for i := 1; i <= int(math.Sqrt(float64(num))); i++ {
		if num%i == 0 {
			result = append(result, i)
			result = append(result, num/i)
		}
	}

	return result
}

func gcd(a, b int) int {
	if a == 0 {
		return b
	}

	return gcd(b%a, a)
}

func printMatrix(matrix [][]int) {
	for i := range matrix {

		for j := range matrix[i] {
			fmt.Printf("%d ", matrix[i][j])
		}

		fmt.Println()

	}
}

func checkPrime(num int) bool {

	if num < 2 {
		return false
	}

	for i := 2; i <= int(math.Sqrt(float64(num))); i++ {
		if num%i == 0 {
			return false
		}
	}

	return true
}

func getPower() {
	A := []int{}

	for i := 1; i <= 38; i++ {
		A = append(A, i)
	}

	for j := 0; j < 10000; j++ {
		for i := range A {
			target, _ := rand.Int(rand.Reader, big.NewInt(38))
			A[i], A[target.Int64()] = A[target.Int64()], A[i]
		}
	}

	B, _ := rand.Int(rand.Reader, big.NewInt(8))

	result := A[:6]
	sort.Ints(result)

	fmt.Println(result)
	fmt.Println(int(B.Int64()) + 1)
}

func xor(a, b int) int {
	aBit := strconv.FormatInt(int64(a), 2)
	bBit := strconv.FormatInt(int64(b), 2)

	size := max(len(aBit), len(bBit))

	for i := size - len(aBit); i > 0; i-- {
		aBit = "0" + aBit
	}
	for i := size - len(bBit); i > 0; i-- {
		bBit = "0" + bBit
	}

	result := ""
	for i := range aBit {
		if aBit[i] == bBit[i] {
			result += "0"
		} else {
			result += "1"
		}
	}

	//fmt.Println(result)
	num, _ := strconv.ParseInt(result, 2, 64)

	return int(num)
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)
		sig := 1 << (bits.Len(uint(n)) - 1)
		if sig >= n {
			sig /= 2
		}

		arr := make([]int, n)
		pos := 0
		for k := sig - 1; k >= 0; k-- {
			arr[pos] = k
			pos++
		}

		for i := 0; pos+i < n; i++ {
			arr[pos+i] = sig + i
		}

		for _, v := range arr {
			fmt.Fprintf(out, "%d ", v)
		}
		fmt.Fprintln(out)
	}
}

//nolint
package main

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

//{
var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	Main()
}

func Main() {
	var t int
	scan(&t)
	for ; t > 0; t-- {
		Solve()
	}
}

//}

func Solve() {
	var n int
	scan(&n)

	k := math.Log2(float64(n - 1))
	k = math.Floor(k)
	for i := n - 1; i >= 1<<int(k); i-- {
		print(i, " ")
	}
	for i := 0; i < 1<<int(k); i++ {
		print(i, " ")
	}
	println()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"math/bits"
	"os"
	"strings"
)

func roundToBitNum(a uint) int {
	return int(math.Pow(2, float64(bits.Len(a)-1)))
}

func helper(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	round := 0
	target := uint(0)
	Fscan(in, &round)

	for i := 1; i <= round; i++ {
		Fscan(in, &target)
		res := make([]int, target)
		target--
		nearestBit := roundToBitNum(target)
		count := 0
		for j := int(target); j >= nearestBit; j-- {
			res[count] = j
			count++
		}
		res[count] = 0
		count++
		for j := nearestBit - 1; j >= 1; j-- {
			res[count] = j
			count++
		}
		Fprintln(out, strings.Trim(Sprint(res), "[]"))
	}
}
func main() { helper(os.Stdin, os.Stdout) }

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	var tt int
	fmt.Fscanf(in, "%d\n", &tt)
	for ; tt > 0; tt-- {
		var n int
		fmt.Fscanf(in, "%d\n", &n)
		k := 1
		for i := 31; i >= 0; i-- {
			if (n-1) & (1 << i) != 0 {
				k = i
				break
			}
		}

		ans := make([]int, 0, n)
		for i := (1<<k)-1; i >= 0; i-- {
			ans = append(ans, i)
		}
		for i := (1<<k); i < n; i++ {
			ans = append(ans, i)
		}
		for i := 0; i < n; i++ {
			fmt.Fprintf(out, "%d ", ans[i])
		}
		fmt.Fprintln(out, "")
	}
	out.Flush()
}

package main

import (
    "fmt"
)

func main() {
    t := 0
    fmt.Scanf("%d\n", &t)
    for t > 0 {
        n := 0
        fmt.Scanf("%d\n", &n)
        n--
        fmt.Print(n)
        p := 0
        for p < n{
            x := p ^ n
            if (x & (x - 1)) == 0 {
                // fmt.Printf(" %d", p)
                break
            }
            p++
        }
        for i := 0; i < n; i++ {
            if i != p {
                // fmt.Printf(" %d", i)
            }
        }
        fmt.Println()
        t--
    }
}

package main

import (
    "fmt"
)

func main() {
    t := 0
    fmt.Scanf("%d\n", &t)
    for t > 0 {
        n := 0
        fmt.Scanf("%d\n", &n)
        n--
        fmt.Print(n)
        p := 0
        for p < n{
            x := p ^ n
            if (x & (x - 1)) == 0 {
                fmt.Printf(" %d", p)
                break
            }
            p++
        }
        for i := 0; i < n; i++ {
            if i != p {
                fmt.Printf(" %d", i)
            }
        }
        fmt.Println()
        t--
    }
}

package main

import (
    "fmt"
)

func main() {
    t := 0
    fmt.Scanf("%d", &t)
    for t > 0 {
        n := 0
        fmt.Scanf("%d", &n)
        n--
        fmt.Print(n)
        p := 0
        for p < n{
            x := p ^ n
            if (x & (x - 1)) == 0 {
                fmt.Printf(" %d", p)
                break
            }
            p++
        }
        for i := 0; i < n; i++ {
            if i != p {
                fmt.Printf(" %d", i)
            }
        }
        fmt.Println()
        t--
    }
}

package main

import (
	"fmt"
)

func solve() {
	var n int
	fmt.Scanf("%d\n", &n)
	k := 0
	for 1<<(k+1) <= n-1 {
		k++
	}
	for i := (1 << k) - 1; i >= 0; i-- {
		fmt.Printf("%d ", i)
	}
	for i := (1 << k); i <= n; i++ {
		fmt.Printf("%d ", i)
	}
	fmt.Println()
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for t > 0 {
		solve()
		t--
	}
}

package main

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

func solve(){
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s, _ := strconv.Atoi(scanner.Text())
	for i :=0; i<s; i++ {
		if (s/2-i)%s < 0 {
			fmt.Print(s/2-(s/2-i)%s)
		} else{
			fmt.Print((s/2-i)%s)
		}
		fmt.Print(" ")
		// fmt.Print((s/2-i)%s)
	}
	fmt.Println()
}

func main(){
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t , _ := strconv.ParseInt(scanner.Text(), 10, 32)
	for t > 0 {
		solve()
		t--
	}
	fmt.Println(t)
}

package main

import (
	"bufio"
	"crypto/rand"
	"fmt"
	"math"
	"math/big"
	"os"
	"sort"
	"strconv"
)

func main() {

	reader := bufio.NewReader(os.Stdin)
	writter := bufio.NewWriter(os.Stdout)
	defer writter.Flush()

	t := 0
	fmt.Fscan(reader, &t)

	for t > 0 {
		n := 0
		fmt.Fscan(reader, &n)

		p := solve(n)
		for i := range p {
			fmt.Fprintf(writter, "%d ", p[i])
		}
		fmt.Fprintln(writter)

		t--
	}

	// n := 6
	// fmt.Println(solve(n))

}

func solve(n int) []int {

	result := []int{0}
	flag := false

	for i := 1; i < n; i++ {

		if flag {
			result = append(result, i)
		} else {
			temp := []int{i}
			temp = append(temp, result...)
			result = temp
		}

		flag = !flag

	}

	return result
}

func arraySum(array []int) int {
	sum := 0

	for i := range array {
		sum += array[i]
	}

	return sum
}

func numSum(num int) int {
	sum := 0

	for i := num; i > 0; i-- {
		sum += i
	}

	return sum
}

func strToint(str string) int {
	num, _ := strconv.Atoi(str)
	return num
}

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

	return b
}

func getFactor(num int) []int {
	result := []int{}

	for i := 1; i <= int(math.Sqrt(float64(num))); i++ {
		if num%i == 0 {
			result = append(result, i)
			result = append(result, num/i)
		}
	}

	return result
}

func gcd(a, b int) int {
	if a == 0 {
		return b
	}

	return gcd(b%a, a)
}

func printMatrix(matrix [][]int) {
	for i := range matrix {

		for j := range matrix[i] {
			fmt.Printf("%d ", matrix[i][j])
		}

		fmt.Println()

	}
}

func checkPrime(num int) bool {

	if num < 2 {
		return false
	}

	for i := 2; i <= int(math.Sqrt(float64(num))); i++ {
		if num%i == 0 {
			return false
		}
	}

	return true
}

func getPower() {
	A := []int{}

	for i := 1; i <= 38; i++ {
		A = append(A, i)
	}

	for j := 0; j < 10000; j++ {
		for i := range A {
			target, _ := rand.Int(rand.Reader, big.NewInt(38))
			A[i], A[target.Int64()] = A[target.Int64()], A[i]
		}
	}

	B, _ := rand.Int(rand.Reader, big.NewInt(8))

	result := A[:6]
	sort.Ints(result)

	fmt.Println(result)
	fmt.Println(int(B.Int64()) + 1)
}

package main

import (
	"bufio"
	"crypto/rand"
	"fmt"
	"math"
	"math/big"
	"os"
	"sort"
	"strconv"
)

func main() {

	reader := bufio.NewReader(os.Stdin)
	writter := bufio.NewWriter(os.Stdout)
	defer writter.Flush()

	t := 0
	fmt.Fscan(reader, &t)

	for t > 0 {
		n := 0
		fmt.Fscan(reader, &n)

		p := solve(n)
		for i := range p {
			fmt.Fprintf(writter, "%d ", p[i])
		}
		fmt.Fprintln(writter)

		t--
	}

	// n := 6
	// fmt.Println(solve(n))

}

func solve(n int) []int {

	result := []int{0}
	flag := false

	for i := 1; i <= n; i++ {

		if flag {
			result = append(result, i)
		} else {
			temp := []int{i}
			temp = append(temp, result...)
			result = temp
		}

		flag = !flag

	}

	return result
}

func arraySum(array []int) int {
	sum := 0

	for i := range array {
		sum += array[i]
	}

	return sum
}

func numSum(num int) int {
	sum := 0

	for i := num; i > 0; i-- {
		sum += i
	}

	return sum
}

func strToint(str string) int {
	num, _ := strconv.Atoi(str)
	return num
}

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

	return b
}

func getFactor(num int) []int {
	result := []int{}

	for i := 1; i <= int(math.Sqrt(float64(num))); i++ {
		if num%i == 0 {
			result = append(result, i)
			result = append(result, num/i)
		}
	}

	return result
}

func gcd(a, b int) int {
	if a == 0 {
		return b
	}

	return gcd(b%a, a)
}

func printMatrix(matrix [][]int) {
	for i := range matrix {

		for j := range matrix[i] {
			fmt.Printf("%d ", matrix[i][j])
		}

		fmt.Println()

	}
}

func checkPrime(num int) bool {

	if num < 2 {
		return false
	}

	for i := 2; i <= int(math.Sqrt(float64(num))); i++ {
		if num%i == 0 {
			return false
		}
	}

	return true
}

func getPower() {
	A := []int{}

	for i := 1; i <= 38; i++ {
		A = append(A, i)
	}

	for j := 0; j < 10000; j++ {
		for i := range A {
			target, _ := rand.Int(rand.Reader, big.NewInt(38))
			A[i], A[target.Int64()] = A[target.Int64()], A[i]
		}
	}

	B, _ := rand.Int(rand.Reader, big.NewInt(8))

	result := A[:6]
	sort.Ints(result)

	fmt.Println(result)
	fmt.Println(int(B.Int64()) + 1)
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)
		sig := 1 << (bits.Len(uint(n)) - 1)

		arr := make([]int, n)
		pos := 0
		for k := sig - 1; k >= 0; k-- {
			arr[pos] = k
			pos++
		}

		for i := 0; pos+i < n; i++ {
			arr[pos+i] = sig + i
		}

		for _, v := range arr {
			fmt.Fprintf(out, "%d ", v)
		}
		fmt.Fprintln(out)
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)
		sig := 1 << (bits.Len(uint(n)) - 1)

		arr := make([]int, n)
		pos := 0
		for k := n - 1; k > sig; k-- {
			arr[pos] = k
			if pos < n-2 {
				pos++
				arr[pos] = k - sig
			}
			pos++
		}

		k := sig - 1
		for i := pos; i < n-2; i++ {
			arr[i] = k
			k--
		}

		arr[n-2] = 0
		if n-1 < sig {
			arr[n-1] = n - 1
		} else {
			arr[n-1] = sig
		}

		for _, v := range arr {
			fmt.Fprintf(out, "% d", v)
		}
		fmt.Fprintln(out)
	}
}

//nolint
package main

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

//{
var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	Main()
}

func Main() {
	var t int
	scan(&t)
	for ; t > 0; t-- {
		Solve()
	}
}

//}

func Solve() {
	var n int
	scan(&n)

	k := math.Log2(float64(n - 1))
	k = math.Ceil(k)
	println("k:", k)
	for i := n - 1; i >= 2^int(k); i-- {
		print(i, " ")
	}
	for i := 0; i < 2^int(k); i++ {
		print(i, " ")
	}
	println()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"math/bits"
	"os"
)

func roundToBitNum(a uint) int {
	return int(math.Pow(2, float64(bits.Len(a)-1)))
}

func helper(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	round := 0
	target := uint(0)
	Fscan(in, &round)

	for i := 1; i <= round; i++ {
		Fscan(in, &target)
		res := make([]int, target)
		target--
		nearestBit := roundToBitNum(target)
		count := 0
		for j := int(target); j >= nearestBit; j-- {
			res[count] = j
			count++
		}
		res[count] = 0
		count++
		for j := nearestBit - 1; j >= 1; j-- {
			res[count] = j
			count++
		}
		Fprintln(out, res)
	}
}
func main() { helper(os.Stdin, os.Stdout) }

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	var tt int
	fmt.Fscanf(in, "%d\n", &tt)
	for ; tt > 0; tt-- {
		var n int
		fmt.Fscanf(in, "%d\n", &n)
		k := 1
		for i := 31; i >= 0; i-- {
			if n & (1 << i) != 0 {
				k = i
				break
			}
		}

		ans := make([]int, 0, n)
		for i := (1<<k)-1; i >= 0; i-- {
			ans = append(ans, i)
		}
		for i := (1<<k); i < n; i++ {
			ans = append(ans, i)
		}
		for i := 0; i < n; i++ {
			fmt.Fprintf(out, "%d ", ans[i])
		}
		fmt.Fprintln(out, "")
	}
	defer out.Flush()
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

// ----------------------------- TEMPLATE END ----------------------------------

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		var n int
		scan(&n)
		var p2 = 1
		for p2*2 <= n {
			p2 *= 2
		}
		for i := p2 - 1; i >= 0; i-- {
			printf("%d ", i)
		}
		for i := p2; i < n; i++ {
			printf("%d ", i)
		}
		printf("\n")
	}
}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// https://space.bilibili.com/206214/dynamic
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(curCase int) {
		var n,k int
		Fscan(in, &n,&k)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		b := make([]int, n-1)
		for i := 0; i < n-1; i++ {
			if a[i]<2*a[i+1] {
				b[i] = 1
			}
		}
		sum := make([]int, len(b)+1)
		for i, v := range b {
			sum[i+1] = sum[i] + v
		}
		ans := 0
		for i := k; i < len(sum); i++ {
			if sum[i]-sum[i-k] == k {
				ans++
			}
		}
		Fprintln(out, ans)
	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

	leftData, _ := ioutil.ReadAll(in)
	if s := strings.TrimSpace(string(leftData)); s != "" {
		panic("有未读入的数据：\n" + s)
	}

}

func main() { run(os.Stdin, os.Stdout) }

package main

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

var in = bufio.NewReader(os.Stdin)

func readInt() int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLine() []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	values := strings.Split(line, " ")
	return values
}

func readArrInt() []int {
	line := readLine()
	res := make([]int, 0, 0)
	for i := range line {
		var x, _ = strconv.Atoi(line[i])
		res = append(res, x)
	}
	return res
}

func main() {
	test := readInt()
	for ; 0 < test; test-- {
		ar := readArrInt()
		var n, k int
		n, k = ar[0], ar[1]
		a := readArrInt()
		b := make([]int, n, n)
		for i := 0; i+1 < n; i++ {
			if a[i+1]*2 <= a[i] {
				b[i+1] = 1
			}
			b[i+1] += b[i]
		}
		res := 0
		for i := 0; i+k < n; i++ {
			if b[i] == b[i+k] {
				res++
			}
		}
		fmt.Println(res)
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func readInt() int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLine() []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	values := strings.Split(line, " ")
	return values
}

func readArrInt() []int {
	line := readLine()
	res := make([]int, 0, 0)
	for i := range line {
		var x, _ = strconv.Atoi(line[i])
		res = append(res, x)
	}
	return res
}

func main() {
	test := readInt()
	for ; 0 < test; test-- {
		ar := readArrInt()
		var n, k int
		n, k = ar[0], ar[1]
		a := readArrInt()
		b := make([]int, n, n)
		for i := 0; i+1 < n; i++ {
			if a[i+1]*2 <= a[i] {
				b[i+1] = 1
			}
			b[i+1] += b[i]
		}
		res := 0
		for i := 0; i+k < n; i++ {
			if b[i] == b[i + k] {
				res++
			}
		}
		fmt.Println(res)
	}
}

package main

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

func main() {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T, n, k, a int
	fmt.Fscan(in, &T)
	for i := 0; i < T; i++ {

		fmt.Fscan(in, &n, &k)
		cnt, ans := 0, 0
		for j := 0; j < n; j++ {

			var x int
			fmt.Fscan(in, &x)
			if j > 0 {

				if a < x * 2 {

					cnt += 1
					if cnt >= k {

						ans += 1
					}
				} else {

					cnt = 0
				}
			}
			a = x
		}

		fmt.Fprintln(out, ans)
		//fmt.Fprintln(out, n, k)
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		var k int64
		fmt.Fscan(in, &n, &k)

		a := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}

		var tot int
		cnt := int64(1)
		for i := 1; i < n; i++ {
			if a[i]*2 > a[i-1] {
				cnt++
				if cnt > k {
					tot++
				}
			} else {
				cnt = 1
			}
		}
		fmt.Fprintln(out, tot)
	}
}

package main

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

var _, _, _ = main, rw, do

func main() {
	r, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer w.Flush()
	rw(r, w)
}

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n, k int
		fmt.Fscan(r, &n, &k)
		var a = make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		w1 := do(a, n, k)
		fmt.Fprintln(w, w1)
	}
}

func do(a []int, n, k int) int {
	j := 0
	c := 0
	// log.Print(a)
	for i := 1; i < n; i++ {
		if 2*a[i] <= a[i-1] {
			j = i
		}
		if i-j+1 >= k+1 {
			c++
		}
		// log.Print(i, j, k, c)
	}
	return c
}

package main

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

/*
3
5 2
2 2 3 2 2
5 2
4 4 1 4 4
7 2
4 4 4 4 1 1 1

---
3
1
3
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n, k int
	scanf("%d %d\n", &n, &k)

	a := make([]int, n)

	for i := range a {
		scanf("%d", &a[i])
	}
	scanf("\n")

	ans := 0

	itemsCnt := 1

	for i := 1; i < n; i++ {
		if a[i-1] < 2*a[i] {
			itemsCnt++
		} else {
			arrCnt := itemsCnt - k
			if arrCnt > 0 {
				ans += arrCnt
			}

			itemsCnt = 1
		}
	}

	arrCnt := itemsCnt - k
	if arrCnt > 0 {
		ans += arrCnt
	}

	fmt.Fprintln(writer, ans)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func sum(nums ...int) (sum int) {
	for _, num := range nums {
		sum += num
	}
	return
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int64) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := int64(5); i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

//goland:noinspection GoUnusedFunction
func factorize(num int64) []int64 {
	factors := make([]int64, 0)

	for ftr := int64(2); ftr*ftr <= num; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > 1 {
		factors = append(factors, num)
	}

	return factors
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"runtime/debug"
)

/* begin of MyIO */
const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()
	neg := false
	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	if neg {
		return -x
	}
	return
}

func (myio *MyIO) ReadInt64() (x int64) {
	rc := myio.rc
	b := rc()
	neg := false

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int64(b&15)
	}
	if neg {
		return -x
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

var myio *MyIO

func ri() int {
	return myio.ReadInt()
}

func ri64() int64 {
	return myio.ReadInt64()
}

func ria(_n int) []int {
	a := make([]int, _n)
	for i := range a {
		a[i] = ri()
	}
	return a
}

/* End of MyIO */

func sol() {
	n, k := ri(), ri()
	a := ria(n)
	c := 0
	fi := 0
	for i := 1; i < n; i++ {
		if a[i]*2 > a[i-1] {
			if i-fi >= k {
				c += 1
			}
		} else {
			fi = i
		}
	}
	myio.Println(c)
}

func main() {
	debug.SetGCPercent(-1)
	in, out := os.Stdin, os.Stdout
	myio = NewIO(in, out)
	defer myio.Flush()

	var t = 1
	t = ri()
	for ; t > 0; t-- {
		sol()
	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func slove() {
	var n, k int
	fmt.Fscan(r, &n, &k)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	dp := make([]int, n)
	dp[0] = 1
	ans := 0
	for i:=1;i<n;i++ {
		if nums[i]*2 > nums[i-1] {
			dp[i] = dp[i-1] + 1
		} else {
			dp[i] = 1
		}
		if dp[i] >= k + 1 {
			ans++
		}
	}
	fmt.Fprintln(w, ans)
}

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func readInt() int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLine() []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	values := strings.Split(line, " ")
	return values
}

func readArrInt() []int {
	line := readLine()
	res := make([]int, 0, 0)
	for i := range line {
		var x, _ = strconv.Atoi(line[i])
		res = append(res, x)
	}
	return res
}

func main() {
	test := readInt()
	for ; 0 < test; test-- {
		ar := readArrInt()
		var n, k int
		n, k = ar[0], ar[1]
		a := readArrInt()
		var res int64 = 0
		for i := 0; i+k < n; i++ {
			found := false
			c := int(math.Min(30, float64(k)))
			for j := 1; j <= c; j++ {
				if int64(a[i+j])*int64(math.Pow(2, float64(j))) <= int64(a[i+j-1])*int64(math.Pow(2, float64(j-1))) {
					found = true
				}
			}
			if !found {
				res++
			}
		}
		fmt.Printf("%d\n", res)
	}
}