import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Twos{

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));

        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

        public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

        }

        public String readLine() throws IOException{
            return s.readLine();
        }

        public void close() throws IOException{
            s.close();
        }

    }      //Fastscanner class end

   static FastScanner in=new FastScanner();
   static PrintWriter ww=new PrintWriter(new OutputStreamWriter(System.out));
   public static void main(String args[])throws IOException
   {
   //Main ob=new Main();
   Twos ob=new Twos();
   ob.solve();
   ww.close();
   }
   public void solve()throws IOException
   {
     boolean X=false;
     boolean Y=false;
    String st=in.nextString();
    int len=st.length();
    for(int i=0;i<len-1;i++)
    {
     if((st.charAt(i)=='A')&&(st.charAt(i+1)=='B')&&!X)
             X=true;
     else if((st.charAt(i)=='B')&&(st.charAt(i+1)=='A')&&!X)
           X=true;
    }
     if(X&&X)
        System.out.println("YES");
     else
        System.out.println("NO");
  }
  }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Twos{

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));

        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

        public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

        }

        public String readLine() throws IOException{
            return s.readLine();
        }

        public void close() throws IOException{
            s.close();
        }

    }      //Fastscanner class end

   static FastScanner in=new FastScanner();
   static PrintWriter ww=new PrintWriter(new OutputStreamWriter(System.out));
   public static void main(String args[])throws IOException
   {
   //Main ob=new Main();
   Twos ob=new Twos();
   ob.solve();
   ww.close();
   }
   public void solve()throws IOException
   {
     boolean X=false;
     boolean Y=false;
     boolean z=false;
     String st1=in.nextString();
     String st2=st1.replaceFirst("AB","X").replaceAll("BA","Y");
     String st3=st1.replaceFirst("BA","X").replaceAll("AB","Y");
     //System.out.println(st2);
     for(int i=0;i<st2.length();i++)
     {
       if(st2.charAt(i)=='X')
            X=true;
       if(st2.charAt(i)=='Y')
          Y=true;
     }
     if(X&&Y)
     z=true;

     X=false;
     Y=false;
     for(int i=0;i<st3.length()-1;i++)
     {
       if(st3.charAt(i)=='X')
            X=true;
       if(st3.charAt(i)=='Y')
          Y=true;
     }
     if(X&&Y)z=true;
     if(z)
        System.out.println("YES");
     else
        System.out.println("NO");

  }
  }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Twos{

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));

        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

        public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

        }

        public String readLine() throws IOException{
            return s.readLine();
        }

        public void close() throws IOException{
            s.close();
        }

    }      //Fastscanner class end

   static FastScanner in=new FastScanner();
   static PrintWriter ww=new PrintWriter(new OutputStreamWriter(System.out));
   public static void main(String args[])throws IOException
   {
   //Main ob=new Main();
   Twos ob=new Twos();
   ob.solve();
   ww.close();
   }
   public void solve()throws IOException
   {
     boolean X=false;
     boolean Y=false;
    String st=in.nextString();
    String st2=st.replaceAll("AB","X").replaceAll("BA","X");
    //System.out.println(st2);
   if(st2.contains("A")||st2.contains("B"))
       {
         System.out.println("NO");
         return;
        }
   else
         System.out.println("YES");
    /*int len=st.length();
    if(st.contains("ABA"))
      {
       X=false;
      }
    for(int i=0;i<len-1;i++)
    {
     if((st.charAt(i)=='A')&&(st.charAt(i+1)=='B')&&!X)
             X=true;
     else if((st.charAt(i)=='B')&&(st.charAt(i+1)=='A')&&!X)
           X=true;
    }
     if(X&&X)
        System.out.println("YES");
     else
        System.out.println("NO");
    if(X&&Y)
        System.out.println("NO");*/
  }
  }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Twos{

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));

        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

        public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

        }

        public String readLine() throws IOException{
            return s.readLine();
        }

        public void close() throws IOException{
            s.close();
        }

    }      //Fastscanner class end

   static FastScanner in=new FastScanner();
   static PrintWriter ww=new PrintWriter(new OutputStreamWriter(System.out));
   public static void main(String args[])throws IOException
   {
   //Main ob=new Main();
   Twos ob=new Twos();
   ob.solve();
   ww.close();
   }
   public void solve()throws IOException
   {
    boolean xx=false;
    boolean yy=false;
    boolean zz=false;
    String st=in.nextString();
    int len=st.length();
    for(int i=0;i<len-1;i++)
    {
     if((st.charAt(i)=='A')&&(st.charAt(i+1)=='B')&&!xx)
     {
         i++;
           xx=true;
    }
     else if(xx)
          if((st.charAt(i)=='B')&&(st.charAt(i+1)=='A')&&!yy)
           yy=true;
    }
    if(xx && yy)zz=true;
    xx=yy=false;
    for(int i=0;i<len-1;i++)
    {
     if((st.charAt(i)=='B')&&(st.charAt(i+1)=='A')&&!xx)
       {
         i++;
          xx=true;
        }
     else if(xx)
        if((st.charAt(i)=='A')&&(st.charAt(i+1)=='B')&&!yy)
           yy=true;
     }
     if(xx && yy)zz=true;
     if(zz)System.out.println("YES");
     else
        System.out.println("NO");

  }
  }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Twos{

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));

        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

        public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

        }

        public String readLine() throws IOException{
            return s.readLine();
        }

        public void close() throws IOException{
            s.close();
        }

    }      //Fastscanner class end

   static FastScanner in=new FastScanner();
   static PrintWriter ww=new PrintWriter(new OutputStreamWriter(System.out));
   public static void main(String args[])throws IOException
   {
   //Main ob=new Main();
   Twos ob=new Twos();
   ob.solve();
   ww.close();
   }
   public void solve()throws IOException
   {
     String y = s.nextString();
        String x = y.replaceFirst("AB", "x").replaceAll("BA", "y");
        String z = y.replaceFirst("BA", "x").replaceAll("AB", "y");

        boolean xx = false;
        boolean yy = false;
        boolean zz = false;

        for(int i=0;i<x.length();i++){
            if(x.charAt(i) == 'x') xx = true;
            if(x.charAt(i) == 'y') yy = true;
        }

        if(xx && yy) zz = true;
        xx = yy = false;

        for(int i=0;i<z.length();i++){
            if(z.charAt(i) == 'x') xx = true;
            if(z.charAt(i) == 'y') yy = true;
        }

        if(xx && yy) zz = true;

        if(zz)System. out.println("YES");
        else System.out.println("NO");

  }
  }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Twos{

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));

        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

        public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

        }

        public String readLine() throws IOException{
            return s.readLine();
        }

        public void close() throws IOException{
            s.close();
        }

    }      //Fastscanner class end

   static FastScanner in=new FastScanner();
   static PrintWriter ww=new PrintWriter(new OutputStreamWriter(System.out));
   public static void main(String args[])throws IOException
   {
   //Main ob=new Main();
   Twos ob=new Twos();
   ob.solve();
   ww.close();
   }
   public void solve()throws IOException
   {
     boolean X=false;
     boolean Y=false;
    String st=in.nextString();
    int len=st.length();
    if(st.contains("ABA"))
      {
       System.out.println("NO");
       return;
      }
    for(int i=0;i<len-1;i++)
    {
     if((st.charAt(i)=='A')&&(st.charAt(i+1)=='B')&&!X)
             X=true;
     else if((st.charAt(i)=='B')&&(st.charAt(i+1)=='A')&&!X)
           X=true;
    }
     if(X&&X)
        System.out.println("YES");
     else
        System.out.println("NO");
  }
  }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Twos{

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));

        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

        public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

        }

        public String readLine() throws IOException{
            return s.readLine();
        }

        public void close() throws IOException{
            s.close();
        }

    }      //Fastscanner class end

   static FastScanner in=new FastScanner();
   static PrintWriter ww=new PrintWriter(new OutputStreamWriter(System.out));
   public static void main(String args[])throws IOException
   {
   //Main ob=new Main();
   Twos ob=new Twos();
   ob.solve();
   ww.close();
   }
   public void solve()throws IOException
   {
     boolean X=false;
     boolean Y=false;
     boolean z=false;
     String st1=in.nextString();
     String st2=st1.replaceFirst("AB","X").replaceAll("BA","Y");
     String st3=st1.replaceFirst("BA","X").replaceAll("AB","Y");
     if(st2.equals(st1)||(st3.equals(st1)))
     {
        System.out.println("NO");
        return;
     }
     for(int i=0;i<st2.length();i++)
     {
       if(st2.charAt(i)=='X')
            X=true;
       if(st2.charAt(i)=='Y')
          Y=true;
     }
     if(X&&Y)
     z=true;

     X=false;
     Y=false;
     for(int i=0;i<st3.length();i++)
     {
       if(st3.charAt(i)=='X')
            X=true;
       if(st3.charAt(i)=='Y')
          Y=true;
     }
     if(X&&Y)z=true;
     if(z)
        System.out.println("YES");
     else
        System.out.println("NO");

  }
  }


import java.util.Scanner;

/**
 * Created by sinraf on 6/25/2015.
 */
public class are {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in) ;
        String x = scanner.nextLine() ;
        String x1 , x2 ;
        if(x.contains("AB")){
            x1 = x.substring(0,x.indexOf("AB")) ;
            x2 = x.substring(x.indexOf("AB")+2 , x.length()) ;
            if (x1.contains("BA") || x2.contains("BA")){
                System.out.println("YES");
                return ;
            }
        }
        if(x.contains("BA")){
            x1 = x.substring(0,x.indexOf("BA")) ;
            x2 = x.substring(x.indexOf("BA")+2 , x.length()) ;
            if (x1.contains("AB") || x2.contains("AB")){
                System.out.println("YES");
                return ;
            }
        }
        System.out.println("NO");
    }
}


import java.util.Scanner;

/**
 * Created by sinraf on 6/25/2015.
 */
public class are {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in) ;
        String x = scanner.nextLine() ;
        for ( ; x.contains("AB") ;){
            x = x.substring(0 , x.indexOf("AB")) + x.substring(x.indexOf("AB")+2 , x.length()) ;
            //System.out.println(x);
            if (x.contains("BA")){
                System.out.println("YES");
                return ;
            }
        }
        System.out.println("NO");
    }
}


import java.util.Scanner;

/**
 * Created by sinraf on 6/25/2015.
 */
public class are {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in) ;
        String x = scanner.nextLine() ;
        String x1 , x2 ;
        if(x.contains("AB")){
            x1 = x.substring(0,x.indexOf("AB")) ;
            x2 = x.substring(x.indexOf("AB")+2 , x.length()) ;
            if (x1.contains("BA") || x2.contains("BA")){
                System.out.println("YES");
                return ;
            }
        }
        System.out.println("NO");
    }
}


import java.util.Scanner;

/**
 * Created by sinraf on 6/25/2015.
 */
public class are {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in) ;
        String x = scanner.nextLine() ;
        if (x.contains("AB")){
            x = x.replaceAll("AB" , " ") ;
            if (x.contains("BA")){
                System.out.println("YES");
                return ;
            }
        }
        System.out.println("NO");
    }
}


import java.util.Scanner;

/**
 * Created by sinraf on 6/25/2015.
 */
public class are {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in) ;
        String x = scanner.nextLine() ;
        if(x.contains("AB")){
            x = x.substring(0,x.indexOf("AB")) + x.substring(x.indexOf("AB")+2 , x.length()) ;
            if (x.contains("BA")){
                System.out.println("YES");
                return ;
            }
        }
        System.out.println("NO");
    }
}


import java.util.Scanner;

/**
 * Created by sinraf on 6/25/2015.
 */
public class are {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in) ;
        String x = scanner.nextLine() ;
        if (x.contains("AB")){
            x.replaceAll("AB" , "") ;
            if (x.contains("BA")){
                System.out.println("YES");
            }
        }
        System.out.println("NO");
    }
}


//package programpractise;
import java.util.Scanner;

public class Main3 {
	public static void main(String []args){
		Scanner scan=new Scanner(System.in);
		boolean ab=false,ba=false,aba=false,bab=false;
		String input=scan.nextLine();
		for(int i=0;i<input.length();i++){
			if((i+2<input.length())&&(input.charAt(i)=='A'&&input.charAt(i+1)=='B'&&input.charAt(i+2)=='A'))
				{
				aba=true;i+=2;
				}

			if((i+2<input.length())&&(input.charAt(i)=='B'&&input.charAt(i+1)=='A'&&input.charAt(i+2)=='B'))
				{
				bab=true;i+=2;
				}

			if((i+1<input.length())&&(input.charAt(i)=='A'&&input.charAt(i+1)=='B'))
				{
				ab=true;
				continue;
				}
			if((i+1<input.length())&&(input.charAt(i)=='B'&&input.charAt(i+1)=='A'))
				{
				ba=true;
				continue;
				}
		}

		if(((aba||bab)&&(ab||ba))||(ab&ba))
			System.out.println("YES");
		else
			System.out.println("NO");

	}

}


//package programpractise;
import java.util.Scanner;

public class Main3 {
	public static void main(String []args){
		Scanner scan=new Scanner(System.in);
		String input=scan.nextLine();
		scan.close();
		int i,a=0,b=0;
		for(i=0;i<input.length()-1;i++){
		if(input.charAt(i)=='A'&&input.charAt(i+1)=='B'&&i+1<input.length()){ a=1;i++;continue;}
		if(input.charAt(i)=='B'&&input.charAt(i+1)=='A'&&i+1<input.length()){ b=1;i++;continue;}
		if(a==1&&b==1) break;
		}
		if(a==1&&b==1)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

}


//package programpractise;
import java.util.Scanner;

public class Main3 {
	public static void main(String []args){
		Scanner scan=new Scanner(System.in);
		String input=scan.nextLine();
		scan.close();
		int i,a=0,b=0;
		boolean e=true,f=true;
		for(i=0;i<input.length()-1;i++){
		if(input.charAt(i)=='A'&&e&&input.charAt(i+1)=='B'&&i+1<input.length()){ a=1;i++;e=false;continue;}
		if(input.charAt(i)=='B'&&f&&input.charAt(i+1)=='A'&&i+1<input.length()){ b=1;i++;f=false;continue;}
		if(a==1&&b==1) break;
		}
		if(a==1&&b==1)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

}


//package programpractise;
import java.util.Scanner;

public class Main3 {
	public static void main(String []args){
		Scanner scan=new Scanner(System.in);
		boolean ab=false,ba=false,aba=false,bab=false;
		String input=scan.nextLine();
		for(int i=0;i<input.length();i++){
			if((i+2<input.length())&&(input.charAt(i)=='A'&&input.charAt(i+1)=='B'&&input.charAt(i+2)=='A'))
				{
				aba=true;i+=2;
				}

			else if((i+2<input.length())&&(input.charAt(i)=='B'&&input.charAt(i+1)=='A'&&input.charAt(i+2)=='B'))
				{
				bab=true;i+=2;
				}
			else if((i+1<input.length())&&(input.charAt(i)=='A'&&input.charAt(i+1)=='B'))
				{
				ab=true;
				}
			else if((i+1<input.length())&&(input.charAt(i)=='B'&&input.charAt(i+1)=='A'))
				{
				ba=true;
				}
		}
		if(((aba||bab)&&(ab||ba))||(ab&ba)||(aba&bab))
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class A {
    public static void main(String []args) throws IOException{
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String s = bf.readLine();

        if (s.contains("AB")){
            if (s.contains("BA")){
            if (s.substring(0, s.indexOf("AB")).contains("BA") || s.substring(s.indexOf("AB") + 2, s.length()).contains("BA")
                    || s.substring(0, s.indexOf("BA")).contains("AB") || s.substring(s.indexOf("BA") + 2, s.length()).contains("AB") ){
                System.out.println("YES");
            }
            else {
                System.out.println("NO");
            }
            }
            else{
                System.out.println("NO");
            }
            }else{
                    System.out.println("NO");
            }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class A {
	public static void main(String []args) throws IOException{
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String s = bf.readLine();
		boolean[] tried = new boolean[s.length()];
		boolean AB = false;
		boolean BA = false;

			for (int j =0;j<s.length() -1;j++){
				if (!tried[j] && !tried[j+1]){
			 if(!BA && s.charAt(j) == 'B' && s.charAt(j+1) =='A'){
						tried[j] = true;
						tried[j+1] = true;
						BA= true;
			 }
				}
				}
			for (int i =0;i<s.length() -1;i++){
				if (!tried[i] && !tried[i+1]){
				 if(!AB && s.charAt(i) == 'A' && s.charAt(i+1) == 'B'){
					tried[i] = true;
					tried[i+1] = true;
					AB = true;
				}
				}
			}

		if (BA && AB)
		System.out.println("YES");
		else{
			BA = false;
			AB = false;
			for (int i =0;i<s.length() -1;i++){
				if (!tried[i] && !tried[i+1]){
				 if(!AB && s.charAt(i) == 'A' && s.charAt(i+1) == 'B'){
					tried[i] = true;
					tried[i+1] = true;
					AB = true;
				}
				}
				for (int j =0;j<s.length() -1;j++){
					if (!tried[j] && !tried[j+1]){
				 if(!BA && s.charAt(j) == 'B' && s.charAt(j+1) =='A'){
							tried[j] = true;
							tried[j+1] = true;
							BA= true;
				 }
					}
					}

				}

			if (BA && AB)
				System.out.println("YES");
			else
			System.out.println("NO");
	}
	}

}


#include <cstdio>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long double ld;

const int Maxn = 505;
const ld eps = 1e-12l;
const int Maxk = 102;

struct matrix {
	ld m[Maxk][Maxk];
	matrix(ld diag = 0.0l) {
		for (int i = 0; i < Maxk; i++)
			for (int j = 0; j < Maxk; j++)
				m[i][j] = (i == j) * diag;
	}
	matrix operator *(const matrix &b) const {
		matrix c;
		for (int i = 0; i < Maxk; i++)
			for (int j = 0; j < Maxk; j++)
				for (int l = 0; l < Maxk; l++)
					c.m[i][j] += m[i][l] * b.m[l][j];
		return c;
	}
};

int n, m, k;
int trap[Maxn];
int neigh[Maxn][Maxn], tot[Maxn];
ld A[Maxn][Maxn], INV[Maxn][Maxn];
ld st[Maxn];
matrix TR;
int id, myid[Maxn];

void Swap(ld M[][Maxn], int r1, int r2)
{
	for (int i = 1; i <= n; i++)
		swap(M[r1][i], M[r2][i]);
}

void Add(ld M[][Maxn], int r2, ld mult, int r1)
{
	for (int i = 1; i <= n; i++)
		M[r2][i] += mult * M[r1][i];
}

void Mult(ld M[][Maxn], int r, ld mult)
{
	for (int i = 1; i <= n; i++)
		M[r][i] *= mult;
}

ld Get(ld M[][Maxn], ld cur[], int r)
{
	ld res = 0.0;
	for (int j = 1; j <= n; j++)
		res += M[r][j] * cur[j];
	return res;
}

ld getRes(int p)
{
	matrix R(1), A = TR;
	while (p) {
		if (p & 1) R = R * A;
		p >>= 1; A = A * A;
	}
	ld res = 0.0;
	for (int j = 0; j < id; j++)
		res += R.m[id - 1][j] * st[j];
	return res;
}

int main()
{
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= n; i++)
		scanf("%d", &trap[i]);
	while (m--) {
		int a, b; scanf("%d %d", &a, &b);
		neigh[a][b]++; tot[a]++;
		neigh[b][a]++; tot[b]++;
	}
	for (int i = 1; i <= n; i++) {
		A[i][i] = INV[i][i] = 1.0;
		for (int j = 1; j <= n; j++) if (i != j && !trap[j])
			A[i][j] -= ld(neigh[i][j]) / ld(tot[i]);
	}
	for (int i = 1; i <= n; i++) {
		int j = i;
		while (fabs(A[j][i]) < eps) j++;
		if (j != i) { Swap(A, i, j); Swap(INV, i, j); }
		for (int l = j + 1; l <= n; l++) {
			ld mult = -A[l][i] / A[i][i];
			Add(A, l, mult, i); Add(INV, l, mult, i);
		}
	}
	for (int i = n; i > 0; i--) {
		for (int j = i + 1; j <= n; j++) {
			ld tmp = -A[i][j];
			Add(A, i, tmp, j); Add(INV, i, tmp, j);
		}
		ld mult = 1.0 / A[i][i];
		Mult(A, i, mult); Mult(INV, i, mult);
	}

	for (int i = 1; i <= n; i++) if (trap[i])
		myid[i] = id++;
	ld cur[Maxn];
	for (int i = 1; i <= n; i++) if (trap[i]) {
		for (int j = 1; j <= n; j++)
			cur[j] = ld(neigh[j][i]) / ld(tot[j]);
		st[myid[i]] = Get(INV, cur, 1);
		for (int j = 1; j <= n; j++) if (trap[j])
			TR.m[myid[i]][myid[j]] = Get(INV, cur, j);
	}
	cout << fixed << setprecision(8) << getRes(k - 2) << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 107 , __ = 507 , _e = 100007;

int pcnt=0;

struct martix
{
	double val[_][_];

	martix(){memset(val,0,sizeof(val));}

	void be0(){memset(val,0,sizeof(val));}
	void be1(){memset(val,0,sizeof(val));for(int i=1;i<=pcnt;i++)val[i][i]=1;}

	double* operator [] (int x){return val[x];}

	friend martix operator * (martix a,martix b)
	{
		martix c;
		for(int i=1;i<=pcnt;i++)
			for(int j=1;j<=pcnt;j++)
				for(int k=1;k<=pcnt;k++)
					c[i][j]+=a[i][k]*b[k][j];
		return c;
	}
};

martix powa(martix a,lint t)
{
	martix b;b.be1();
	while(t){if(t&1)b=b*a;a=a*a,t>>=1;}
	return b;
}

int n,m,hp;
int got[_]={0},who[__]={0},ea[_e],eb[_e],du[__]={0};

double f[__][__+_]={0};

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty(),m=ty(),hp=ty();
	for(int i=1;i<=n;i++)if(ty())got[++pcnt]=i,who[i]=pcnt;
	for(int i=1;i<=m;i++)ea[i]=ty(),eb[i]=ty(),du[ea[i]]++,du[eb[i]]++;

	for(int i=1;i<=m;i++)
	{
		int a=ea[i],b=eb[i];
		if(!who[a])f[b][a]-=1.00/du[a];
		else f[b][n+who[a]]+=1.00/du[a];
		if(!who[b])f[a][b]-=1.00/du[b];
		else f[a][n+who[b]]+=1.00/du[b];
	}

	f[1][n+pcnt+1]=1;
	for(int i=1;i<=n;i++)f[i][i]+=1;

	for(int i=1;i<=n;i++)
	{
		int bias=i;
		for(int j=i;j<=n;j++)
			if(fabs(f[j][i])>fabs(f[bias][i]))bias=j;
		if(i!=bias)for(int j=i;j<=n+pcnt+1;j++)swap(f[i][j],f[bias][j]);
		double fx=f[i][i];
		for(int j=1;j<=n+pcnt+1;j++)f[i][j]/=fx;
		for(int j=1;j<=n;j++)
		{
			if(j==i)continue;
			double temp=f[j][i];
			for(int k=1;k<=n+pcnt+1;k++)f[j][k]-=f[i][k]*temp;
		}
	}

	martix bas,tran;
	for(int i=1;i<=pcnt;i++)
		for(int j=1;j<=pcnt;j++)
			tran[i][j]=f[got[j]][n+i];
	for(int i=1;i<=pcnt;i++)
		bas[1][i]=f[got[i]][n+pcnt+1];

	bas=bas*powa(tran,hp-2);
	cout<<setprecision(11)<<fixed<<bas[1][pcnt]<<lf;

	return 0;
}


//package roundFF;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class D2 {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), m = ni(), K = ni();
		int[] trap = na(n);
		int[][] a = new int[n][n];
		int[] deg = new int[n];
		for(int i = 0;i < m;i++){
			int f = ni()-1, t = ni()-1;
			a[f][t]++;
			a[t][f]++;
			deg[f]++;
			deg[t]++;
		}
		double[][] M = new double[n][n];
		for(int i = 0;i < n;i++){
			if(trap[i] == 0){
				for(int j = 0;j < n;j++){
					M[j][i] = (double)a[i][j] / deg[i];
				}
			}
		}

		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				if(i == j){
					M[i][j] = 1 - M[i][j];
				}else{
					M[i][j] = -M[i][j];
				}
			}
		}
		double[][] im = inv(M);

		double[][] tot = new double[n][];

		double[] v = new double[n];
		v[0] = 1;
		tot[0] = mul(im, v);
//		tr(0, tot[0]);

		for(int i = 0;i < n;i++){
			if(trap[i] == 1){
				v = new double[n];
				for(int j = 0;j < n;j++){
					v[j] = (double)a[i][j] / deg[i];
				}
				tot[i] = mul(im, v);
//				tr(i, tot[i]);
			}
		}

		int u = 0;
		int[] map = new int[n];
		Arrays.fill(map, -1);
		for(int i = 0;i < n;i++){
			if(trap[i] == 1)map[u++] = i;
		}
		double[] V = new double[u];
		for(int i = 0;i < u;i++){
			V[i] = tot[0][map[i]];
		}

		double[][] Q = new double[u][u];
		for(int i = 0;i < u;i++){
			double ls = 0;
			for(int j = 0;j < u;j++){
				Q[j][i] = tot[map[i]][map[j]];
				ls += Q[j][i];
			}
			for(int j = 0;j < u;j++){
				Q[j][i] /= ls;
			}
		}
//		tr(Q);

		double[] t = pow(Q, V, K-2);
		out.printf("%.12f\n", t[u-1]);
	}

	public static double[][] p2(double[][] A)
	{
		int n = A.length;
		double[][] C = new double[n][n];
		for(int i = 0;i < n;i++){
			for(int k = 0;k < n;k++){
				for(int j = 0;j < n;j++){
					C[i][j] += A[i][k] * A[k][j];
				}
			}
		}
		return C;
	}

	// A^e*v
	public static double[] pow(double[][] A, double[] v, int m)
	{
		double[][] mu = A;
		double[] r = v;
		for(;m > 0;m>>>=1){
			if((m&1)==1)r = mul(mu, r);
			mu = p2(mu);
		}
		return r;
	}

	public static double[] mul(double[][] A, double[] v)
	{
		int m = A.length;
		int n = v.length;
		double[] w = new double[m];
		for(int i = 0;i < m;i++){
			double sum = 0;
			for(int k = 0;k < n;k++){
				sum += A[i][k] * v[k];
			}
			w[i] = sum;
		}
		return w;
	}

	public static double[][] LU(double[][] mat)
	{
		int n = mat.length;

		double[][] lu = new double[n][];
		for(int i = 0;i < n;i++){
			lu[i] = Arrays.copyOf(mat[i], n);
		}

		for(int i = 0;i < n;i++){
			int z = i;
			for(;z < n && lu[z][i] == 0;z++);
			if(z == n)continue;
			double[] d = lu[z]; lu[z] = lu[i]; lu[i] = d;

			for(int j = i+1;j < n;j++){
				lu[j][i] /= lu[i][i];
				for(int k = i+1;k < n;k++){
					lu[j][k] -= lu[j][i] * lu[i][k];
				}
			}
		}

		return lu;
	}

	public static double[][] invL(double[][] L)
	{
		int n = L.length;
		double[][] il = new double[n][n];
		// row:j, col:i
		for(int i = 0;i < n;i++){
			for(int j = i;j < n;j++){
				double sum = i == j ? 1 : 0;
				for(int k = i;k < j;k++){
					sum -= L[j][k] * il[k][i];
				}
				il[j][i] = sum / L[j][j];
			}
		}
		return il;
	}

	public static double[][] invU(double[][] U)
	{
		int n = U.length;
		double[][] iu = new double[n][n];
		// row:j, col:i
		for(int i = 0;i < n;i++){
			for(int j = i;j < n;j++){
				double sum = i == j ? 1 : 0;
				for(int k = i;k < j;k++){
					sum -= U[k][j] * iu[i][k];
				}
				iu[i][j] = sum / U[j][j];
			}
		}
		return iu;
	}

	public static double[][] inv(double[][] A)
	{
		int n = A.length;
		double[][] lu = LU(A);
		double[][] iu = invU(lu);
		for(int i = 0;i < n;i++)lu[i][i] = 1.0;
		double[][] il = invL(lu);
		return mul(iu, il);
	}

	public static double[][] mul(double[][] A, double[][] B)
	{
		int m = A.length;
		int n = A[0].length;
		int o = B[0].length;
		double[][] C = new double[m][o];
		for(int i = 0;i < m;i++){
			for(int k = 0;k < n;k++){
				for(int j = 0;j < o;j++){
					C[i][j] += A[i][k] * B[k][j];
				}
			}
		}
		return C;
	}

	public static double[] solve(double[][] a, double[] c)
	{
		int n = a.length;
		int[] ps = new int[n];
		for(int i = 0;i < n;i++)ps[i] = i;

		// Forward Elimination
		for(int i = 0;i < n;i++){
			int pivot = -1;
			int from = -1;
			double amax = 0;
			for(int j = i;j < n;j++){
				if(Math.abs(a[ps[j]][i]) > amax){
					amax = Math.abs(a[ps[j]][i]);
					pivot = ps[j];
					from = j;
				}
			}
			if(pivot == -1)return null;
			int d = ps[i]; ps[i] = ps[from]; ps[from] = d;

			for(int j = i+1;j < n;j++){
				a[ps[i]][j] /= a[ps[i]][i];
			}
			c[ps[i]] /= a[ps[i]][i];
			a[ps[i]][i] = 1.0;
			for(int j = i+1;j < n;j++){
				for(int k = i+1;k < n;k++){
					a[ps[j]][k] -= a[ps[j]][i] * a[ps[i]][k];
				}
				c[ps[j]] -= a[ps[j]][i] * c[ps[i]];
				a[ps[j]][i] = 0.0;
			}

		}

		// Back Substitution
		for(int i = n-1;i >= 0;i--){
			for(int j = i-1;j >= 0;j--){
				c[ps[j]] -= a[ps[j]][i] * c[ps[i]];
			}
		}

		double[] ret = new double[n];
		for(int i = 0;i < n;i++){
			ret[i] = c[ps[i]];
		}

		return ret;
	}

	public static double[] S(double[][] T, double[] v)
	{
		int n = T.length;
		double[][] U = new double[n][n];
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				U[i][j] = (i == j ? 1 : 0) - T[i][j];
			}
		}
		return solve(U, v);
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new D2().run(); }

	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    private int n;
    private int[] degree;
    private int[][] edgeCount;
    private boolean[] hasTrap;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        degree = new int[n];
        edgeCount = new int[n][n];
        hasTrap = new boolean[n];
        int trapCount = 0;
        for (int i = 0; i < n; ++i) {
            hasTrap[i] = in.nextInt() == 1;
            if (hasTrap[i])
                ++trapCount;
        }
        for (int i = 0; i < m; ++i) {
            int u = in.nextInt() - 1;
            int v = in.nextInt() - 1;
            ++edgeCount[u][v];
            ++edgeCount[v][u];
            ++degree[u];
            ++degree[v];
        }
        double[][] coef = getCoefficient();
        double[][] base = new double[trapCount][trapCount];
        double[][] first = new double[trapCount][1];
        for (int u = 0, x = 0; u < n; ++u)
            if (hasTrap[u]) {
                for (int v = 0, y = 0; v < n; ++v)
                    if (hasTrap[v]) {
                        double got = 0;
                        for (int z = 0; z < n; ++z)
                            got += coef[u][z] * edgeCount[z][v] / degree[z];
                        base[y][x] = got;
                        ++y;
                    }
                double got = 0;
                for (int z = 0; z < n; ++z) {
                    got += coef[0][z] * edgeCount[z][u] / degree[z];
                    first[x][0] = got;
                }
                ++x;
            }
        out.printf("%.9f\n", matrixMultiply(matrixPow(base, k - 2), first)[trapCount - 1][0]);
    }

    private double[][] matrixPow(double[][] a, int n) {
        double[][] res = unitMatrix(a.length);
        for (; n > 0; n >>= 1) {
            if ((n & 1) == 1)
                res = matrixMultiply(res, a);
            a = matrixMultiply(a, a);
        }
        return res;
    }

    private double[][] matrixMultiply(double[][] a, double[][] b) {
        int m = a.length;
        int n = a[0].length;
        int p = b[0].length;
        double[][] c = new double[m][p];
        for (int i = 0; i < m; ++i)
            for (int j = 0; j < p; ++j) {
                double got = 0;
                for (int k = 0; k < n; ++k)
                    got += a[i][k] * b[k][j];
                c[i][j] = got;
            }
        return c;
    }

    private double[][] unitMatrix(int n) {
        double[][] res = new double[n][n];
        for (int i = 0; i < n; ++i)
            res[i][i] = 1;
        return res;
    }

    private double[][] getCoefficient() {
        double[][] a = new double[n][n];
        double[][] b = new double[n][n];
        for (int i = 0; i < n; ++i) {
            a[i][i] = b[i][i] = 1;
            for (int j = 0; j < n; ++j)
                if (!hasTrap[j])
                    a[i][j] += -1.0 * edgeCount[i][j] / degree[i];
        }
        for (int v = 0; v < n; ++v) {
            for (int e = v + 1; e < n; ++e) {
                double coef = -a[e][v] / a[v][v];
                for (int p = v; p < n; ++p)
                    a[e][p] += coef * a[v][p];
                for (int p = 0; p < n; ++p)
                    b[e][p] += coef * b[v][p];
            }
        }
        double[][] coef = new double[n][];
        for (int e = n - 1; e >= 0; --e) {
            coef[e] = b[e].clone();
            for (int v = e + 1; v < n; ++v)
                for (int p = 0; p < n; ++p)
                    coef[e][p] -= a[e][v] * coef[v][p];
            for (int p = 0; p < n; ++p)
                coef[e][p] /= a[e][e];
        }
        return coef;
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        try {
            while(tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    }


import java.io.IOException;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        int M = in.nextInt();
        int K = in.nextInt();

        N++;
        int[] isTrap = new int[N];
        ArrayList<Integer> traps = new ArrayList<Integer>();
        for (int i = 0; i < N - 1; i++) {
            isTrap[i] = in.nextInt();
            if (isTrap[i] == 1) {
                traps.add(i);
            }
        }
        isTrap[N - 1] = 1;
        traps.add(N - 1);
        int T = traps.size();

        int[] deg = new int[N];
        int[][] adj = new int[N][N];
        for (int i = 0; i < M; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            deg[a]++;
            deg[b]++;
            adj[a][b]++;
            adj[b][a]++;
        }
        adj[N - 1][0]++;
        deg[N - 1]++;

        double[][] C = new double[T][T];
        for (int dest = 0; dest < T; dest++) {
            double[][] A = new double[N][N + 1];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    double prob = (double) adj[i][j] / deg[i];
                    if (isTrap[j] == 0) {
                        A[i][j] = -prob;
                    }
                    else {
                        if (j == traps.get(dest)) {
                            A[i][N] = prob;
                        }
                    }
                }
                A[i][i] = 1.0;
            }

            double[] X = gauss(A);
            for (int i = 0; i < T; i++) {
                C[i][dest] = X[traps.get(i)];
            }
        }

        double[][] R = new double[T][T];
        for (int i = 0; i < T; i++) {
            R[i][i] = 1.0;
        }

        K--;
        while (K > 0) {
            if ((K & 1) > 0) {
                R = mult(R, C);
            }
            C = mult(C, C);
            K >>= 1;
        }

        out.println(R[T - 1][T - 2]);
    }

    private double[][] mult(double[][] A, double[][] B) {
        double[][] C = new double[A.length][B[0].length];
        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < B[0].length; j++) {
                for (int k = 0; k < A[0].length; k++) {
                    C[i][j] += A[i][k] * B[k][j];
                }
            }
        }
        return C;
    }

    private double[] gauss(double[][] A) {
        int N = A.length;
        for (int j = 0; j < N; j++) {
            int i = j;
            for (; i < N && Math.abs(A[i][j]) < 1e-9; i++);
            if (i == N) {
                throw new RuntimeException();
            }

            for (int k = i + 1; k < N; k++) {
                double coef = -A[k][j] / A[i][j];
                for (int q = j; q < N + 1; q++) {
                    A[k][q] += coef * A[i][q];
                }
            }
        }

        double[] x = new double[N];
        for (int i = N - 1; i >= 0; i--) {
            double sum = A[i][N];
            for (int j = i + 1; j < N; j++) {
                sum -= x[j] * A[i][j];
            }
            x[i] = sum / A[i][i];
        }

        return x;
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));

        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        int M = in.nextInt();
        int K = in.nextInt();
        int[] isTrap = new int[N + 1];
        ArrayList<Integer> traps = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            isTrap[i] = in.nextInt();
            if (isTrap[i] == 1) {
                traps.add(i);
            }
        }
        isTrap[N] = 1;
        traps.add(N);

        int T = traps.size();

        int[] deg = new int[N];
        int[][] adj = new int[N][N];
        for (int i = 0; i < M; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            deg[a]++;
            deg[b]++;
            adj[a][b]++;
            adj[b][a]++;
        }

        N++;
        double[][] A = new double[N][N];
        for (int i = 0; i < N - 1; i++) {
            for (int j = 0; j < N - 1; j++) {
                A[i][j] = (double) adj[i][j] / deg[i];
            }
        }
        A[N - 1][0] = 1.0;

        for (int k = 0; k < N; k++) {
            if (isTrap[k] == 0) {
                for (int i = 0; i < N; i++) {
                    for (int j = 0; j < N; j++) {
                        A[i][j] += A[i][k] * A[k][j];
                    }
                }

                for (int i = 0; i < N; i++) {
                    A[i][k] = A[k][i] = 0.0;
                }

                for (int i = 0; i < N; i++) {
                    if (isTrap[i] == 0) {
                        for (int j = 0; j < N; j++) {
                            if (i != j) {
                                A[i][j] /= (1.0 - A[i][i]);
                            }
                        }
                        A[i][i] = 0;
                    }
                }
            }
        }

        double[][] C = new double[T][T];
        for (int i = 0; i < T; i++) {
            for (int j = 0; j < T; j++) {
                C[i][j] = A[traps.get(i)][traps.get(j)];
            }
        }

        double[][] R = new double[T][T];
        for (int i = 0; i < T; i++) {
            R[i][i] = 1.0;
        }

        K--;
        while (K > 0) {
            if ((K & 1) > 0) {
                R = mult(R, C);
            }
            C = mult(C, C);
            K >>= 1;
        }

        out.println(R[T - 1][T - 2]);
    }

    private double[][] mult(double[][] A, double[][] B) {
        double[][] C = new double[A.length][B[0].length];
        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < B[0].length; j++) {
                for (int k = 0; k < A[0].length; k++) {
                    C[i][j] += A[i][k] * B[k][j];
                }
            }
        }
        return C;
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));

        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

}


import java.io.IOException;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        int M = in.nextInt();
        int K = in.nextInt();

        N++;
        int[] isTrap = new int[N];
        ArrayList<Integer> traps = new ArrayList<Integer>();
        for (int i = 0; i < N - 1; i++) {
            isTrap[i] = in.nextInt();
            if (isTrap[i] == 1) {
                traps.add(i);
            }
        }
        isTrap[N - 1] = 1;
        traps.add(N - 1);
        int T = traps.size();

        int[] deg = new int[N];
        int[][] adj = new int[N][N];
        for (int i = 0; i < M; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            deg[a]++;
            deg[b]++;
            adj[a][b]++;
            adj[b][a]++;
        }
        adj[N - 1][0]++;
        deg[N - 1]++;

        double[][] A = new double[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (isTrap[j] == 0) {
                    A[i][j] = (double) -adj[i][j] / deg[i];
                }
            }
            A[i][i] = 1.0;
        }
        double[][] inv = inverse(A);

        double[][] C = new double[T][T];
        for (int dest = 0; dest < T; dest++) {
            for (int i = 0; i < T; i++) {
                for (int j = 0; j < N; j++) {
                    double prob = (double) adj[j][traps.get(dest)] / deg[j];
                    C[i][dest] += inv[traps.get(i)][j] * prob;
                }
            }
        }

        double[][] R = new double[T][T];
        for (int i = 0; i < T; i++) {
            R[i][i] = 1.0;
        }

        K--;
        while (K > 0) {
            if ((K & 1) > 0) {
                R = mult(R, C);
            }
            C = mult(C, C);
            K >>= 1;
        }

        out.println(R[T - 1][T - 2]);
    }

    private double[][] inverse(double[][] A) {
        int N = A.length;
        double[][] B = new double[N][2 * N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                B[i][j] = A[i][j];
            }
            B[i][i + N] = 1.0;
        }

        for (int j = 0; j < N; j++) {
            double coef = B[j][j];
            for (int q = j; q < 2 * N; q++) {
                B[j][q] /= coef;
            }
            for (int i = 0; i < N; i++) {
                if (i != j) {
                    coef = -B[i][j];
                    for (int q = j; q < 2 * N; q++) {
                        B[i][q] += B[j][q] * coef;
                    }
                }
            }
        }

        double[][] C = new double[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                C[i][j] = B[i][j + N];
            }
        }

        return C;
    }

    private double[][] mult(double[][] A, double[][] B) {
        double[][] C = new double[A.length][B[0].length];
        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < B[0].length; j++) {
                for (int k = 0; k < A[0].length; k++) {
                    C[i][j] += A[i][k] * B[k][j];
                }
            }
        }
        return C;
    }

}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));

        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

}


#include<cstdio>
#include<algorithm>
using namespace std;

const int maxn = 501;
const double eps = 1e-9;

int G[maxn][maxn];
int ind[maxn];
int b[maxn];
double equ[maxn][2 * maxn];
double f[maxn][maxn];
double pf[maxn][maxn];
double tmp[maxn][maxn];
int id[maxn];
int n, m, k;
int cnt;

void gauss(double G[maxn][2 * maxn], int n);

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
		if (b[i]) id[i] = ++cnt;
	}
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		ind[u]++;
		ind[v]++;
		G[u][v]++;
		G[v][u]++;
	}
	for (int u = 1; u <= n; u++) {
		equ[u][u] = 1;
		for (int w = 1; w <= n; w++) {
			if (w == u) continue;
			if (b[w]) equ[u][n + w] = (double)G[u][w] / ind[u];
			else equ[u][w] = -(double)G[u][w] / ind[u];
		}
	}
	gauss(equ, n);
	for (int u = 1; u <= n; u++) {
		if (!b[u]) continue;
		for (int v = 1; v <= n; v++) {
			if (!b[v]) continue;
			f[id[u]][id[v]] = equ[u][n + v];
		}
	}
	for (int i = 1; i <= cnt; i++) {
		pf[i][i] = 1;
	}
	k -= 2;
	for (int c = 31; c >= 0; c--) {
		for (int u = 1; u <= cnt; u++) {
			for (int v = 1; v <= cnt; v++) {
				tmp[u][v] = 0;
				for (int w = 1; w <= cnt; w++) {
					tmp[u][v] += pf[u][w] * pf[w][v];
				}
			}
		}
		for (int u = 1; u <= cnt; u++) {
			for (int v = 1; v <= cnt; v++) {
				pf[u][v] = tmp[u][v];
			}
		}
		if (k >> c & 1) {
			for (int u = 1; u <= cnt; u++) {
				for (int v = 1; v <= cnt; v++) {
					tmp[u][v] = 0;
					for (int w = 1; w <= cnt; w++) {
						tmp[u][v] += f[u][w] * pf[w][v];
					}
				}
			}
			for (int u = 1; u <= cnt; u++) {
				for (int v = 1; v <= cnt; v++) {
					pf[u][v] = tmp[u][v];
				}
			}
		}
	}
	double ans = 0;
	for (int v = 1; v <= n; v++) {
		if (b[v]) ans += equ[1][n + v] * pf[id[v]][id[n]];
	}
	printf("%.5lf", ans);
	return 0;
}

void gauss(double G[maxn][2 * maxn], int n) {
	for (int i = 1; i <= n; i++) {
		double xs = G[i][i];
		for (int j = 1; j <= 2 * n; j++) {
			G[i][j] /= xs;
		}
		for (int j = i + 1; j <= n; j++) {
			if (fabs(G[j][i]) < eps) continue;
			double xs = G[j][i];
			for (int k = 1; k <= 2 * n; k++) {
				G[j][k] -= G[i][k] * xs;
			}
		}
	}
	for (int i = n; i >= 1; i--) {
		for (int j = i - 1; j >= 1; j--) {
			if (fabs(G[j][i]) < eps) continue;
			double xs = G[j][i];
			for (int k = 1; k <= 2 * n; k++) {
				G[j][k] -= G[i][k] * xs;
			}
		}
	}
}


#include<cstdio>
#include<algorithm>
using namespace std;

const int maxn = 501;
const double eps = 1e-6;

int G[maxn][maxn];
int ind[maxn];
int b[maxn];
double equ[maxn][2 * maxn];
double f[maxn][maxn];
double pf[maxn][maxn];
double tmp[maxn][maxn];
int id[maxn];
int n, m, k;
int cnt;

void gauss(double G[maxn][2 * maxn], int n);

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
		if (b[i]) id[i] = ++cnt;
	}
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		ind[u]++;
		ind[v]++;
		G[u][v]++;
		G[v][u]++;
	}
	for (int u = 1; u <= n; u++) {
		equ[u][u] = 1;
		for (int w = 1; w <= n; w++) {
			if (w == u) continue;
			if (b[w]) equ[u][n + w] = (double)G[u][w] / ind[u];
			else equ[u][w] = -(double)G[u][w] / ind[u];
		}
	}
	gauss(equ, n);
	for (int u = 1; u <= n; u++) {
		if (!b[u]) continue;
		for (int v = 1; v <= n; v++) {
			if (!b[v]) continue;
			f[id[u]][id[v]] = equ[u][n + v];
		}
	}
	for (int i = 1; i <= cnt; i++) {
		pf[i][i] = 1;
	}
	k -= 2;
	for (int c = 31; c >= 0; c--) {
		for (int u = 1; u <= cnt; u++) {
			for (int v = 1; v <= cnt; v++) {
				tmp[u][v] = 0;
				for (int w = 1; w <= cnt; w++) {
					tmp[u][v] += pf[u][w] * pf[w][v];
				}
			}
		}
		for (int u = 1; u <= cnt; u++) {
			for (int v = 1; v <= cnt; v++) {
				pf[u][v] = tmp[u][v];
			}
		}
		if (k >> c & 1) {
			for (int u = 1; u <= cnt; u++) {
				for (int v = 1; v <= cnt; v++) {
					tmp[u][v] = 0;
					for (int w = 1; w <= cnt; w++) {
						tmp[u][v] += f[u][w] * pf[w][v];
					}
				}
			}
			for (int u = 1; u <= cnt; u++) {
				for (int v = 1; v <= cnt; v++) {
					pf[u][v] = tmp[u][v];
				}
			}
		}
	}
	double ans = 0;
	for (int v = 1; v <= n; v++) {
		if (b[v]) ans += equ[1][n + v] * pf[id[v]][id[n]];
	}
	printf("%.5lf", ans);
	return 0;
}

void gauss(double G[maxn][2 * maxn], int n) {
	for (int i = 1; i <= n; i++) {
		double xs = G[i][i];
		for (int j = 1; j <= 2 * n; j++) {
			G[i][j] /= xs;
		}
		for (int j = i + 1; j <= n; j++) {
			if (fabs(G[j][i]) < eps) continue;
			double xs = G[j][i];
			for (int k = 1; k <= 2 * n; k++) {
				G[j][k] -= G[i][k] * xs;
			}
		}
	}
	for (int i = n; i >= 1; i--) {
		for (int j = i - 1; j >= 1; j--) {
			if (fabs(G[j][i]) < eps) continue;
			double xs = G[j][i];
			for (int k = 1; k <= 2 * n; k++) {
				G[j][k] -= G[i][k] * xs;
			}
		}
	}
}


#include<cstdio>
#include<algorithm>
using namespace std;

const int maxn = 501;
const double eps = 1e-12;

int G[maxn][maxn];
int ind[maxn];
int b[maxn];
double equ[maxn][2 * maxn];
double f[maxn][maxn];
double pf[maxn][maxn];
double tmp[maxn][maxn];
int id[maxn];
int n, m, k;
int cnt;

void gauss(double G[maxn][2 * maxn], int n);

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
		if (b[i]) id[i] = ++cnt;
	}
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		ind[u]++;
		ind[v]++;
		G[u][v]++;
		G[v][u]++;
	}
	for (int u = 1; u <= n; u++) {
		equ[u][u] = 1;
		for (int w = 1; w <= n; w++) {
			if (w == u) continue;
			if (b[w]) equ[u][n + w] = (double)G[u][w] / ind[u];
			else equ[u][w] = -(double)G[u][w] / ind[u];
		}
	}
	gauss(equ, n);
	for (int u = 1; u <= n; u++) {
		if (!b[u]) continue;
		for (int v = 1; v <= n; v++) {
			if (!b[v]) continue;
			f[id[u]][id[v]] = equ[u][n + v];
		}
	}
	for (int i = 1; i <= cnt; i++) {
		pf[i][i] = 1;
	}
	k -= 2;
	for (int c = 31; c >= 0; c--) {
		for (int u = 1; u <= cnt; u++) {
			for (int v = 1; v <= cnt; v++) {
				tmp[u][v] = 0;
				for (int w = 1; w <= cnt; w++) {
					tmp[u][v] += pf[u][w] * pf[w][v];
				}
			}
		}
		for (int u = 1; u <= cnt; u++) {
			for (int v = 1; v <= cnt; v++) {
				pf[u][v] = tmp[u][v];
			}
		}
		if (k >> c & 1) {
			for (int u = 1; u <= cnt; u++) {
				for (int v = 1; v <= cnt; v++) {
					tmp[u][v] = 0;
					for (int w = 1; w <= cnt; w++) {
						tmp[u][v] += f[u][w] * pf[w][v];
					}
				}
			}
			for (int u = 1; u <= cnt; u++) {
				for (int v = 1; v <= cnt; v++) {
					pf[u][v] = tmp[u][v];
				}
			}
		}
	}
	double ans = 0;
	for (int v = 1; v <= n; v++) {
		if (b[v]) ans += equ[1][n + v] * pf[id[v]][id[n]];
	}
	printf("%.5lf", ans);
	return 0;
}

void gauss(double G[maxn][2 * maxn], int n) {
	for (int i = 1; i <= n; i++) {
		double xs = G[i][i];
		for (int j = 1; j <= 2 * n; j++) {
			G[i][j] /= xs;
		}
		for (int j = i + 1; j <= n; j++) {
			if (fabs(G[j][i]) < eps) continue;
			double xs = G[j][i];
			for (int k = 1; k <= 2 * n; k++) {
				G[j][k] -= G[i][k] * xs;
			}
		}
	}
	for (int i = n; i >= 1; i--) {
		for (int j = i - 1; j >= 1; j--) {
			if (fabs(G[j][i]) < eps) continue;
			double xs = G[j][i];
			for (int k = 1; k <= 2 * n; k++) {
				G[j][k] -= G[i][k] * xs;
			}
		}
	}
}


#include <cstdio>
#include <numeric>
#include <memory.h>
#include <vector>
#include <algorithm>

using namespace std;

template<typename elem_t = double>
struct SqMatrix
{
	inline elem_t add (elem_t a, elem_t b) { return a + b; }
	inline elem_t sub (elem_t a, elem_t b) { return a - b; }
	inline elem_t mul (elem_t a, elem_t b) { return a * b; }
	inline elem_t inv (elem_t a) { return 1 / a; }
	inline bool isZero(elem_t a) { return fabs(a) < 1e-9; }

	template<int sz>
	void Multiply(int n, elem_t A[][sz], const elem_t B[][sz]) {
		static elem_t tmp[sz][sz];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				elem_t sum = 0;
				for(int k = 0; k < n; k++) {
					sum = add(sum, mul(A[i][k], B[k][j]));
				}
				tmp[i][j] = sum;
			}
		}
		for(int i = 0; i < n; i++) {
			memcpy(A[i], tmp[i], sizeof(tmp[i][0])*n);
		}
	}

	template<int sz>
	void Multiply(int n, elem_t out[][sz], const elem_t A[][sz], const elem_t B[][sz]) {
		if (out == A) return Multiply(n, A,B);
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				elem_t sum = 0;
				for(int k = 0; k < n; k++) {
					sum = add(sum, mul(A[i][k], B[k][j]));
				}
				out[i][j] = sum;
			}
		}
	}

	template<int sz>
	void Power(int n, elem_t R[][sz], elem_t A[][sz], unsigned long long p) {
		for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) R[i][j] = 0;
		for(int i = 0; i < n; i++) R[i][i] = 1;
		while(p) {
			if (p & 1) Multiply(n,R,A);
			Multiply(n,A,A);
			p >>= 1;
		}
	}

	template<int sz>
	bool Inverse(int n, elem_t out[][sz], elem_t A[][sz]) {
		for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) out[i][j] = 0;
		for(int i = 0; i < n; i++) out[i][i] = 1;
		for(int i = 0; i < n; i++) {
			if (isZero(A[i][i])) {
				elem_t maxValue = 0;
				int maxInd = -1;
				for(int j = i+1; j < n; j++) {
					auto cur = abs(A[j][i]);
					if (maxValue < cur) {
						maxValue = cur;
						maxInd = j;
					}
				}
				if (maxInd == -1 || isZero(A[maxInd][i])) return false;
				for(int k = 0; k < n; k++) A  [i][k] = add(A  [i][k], A  [maxInd][k]);
				for(int k = 0; k < n; k++) out[i][k] = add(out[i][k], out[maxInd][k]);
			}
			elem_t coeff = inv(A[i][i]);
			for(int j = 0; j < n; j++) A  [i][j] = mul(A  [i][j], coeff);
			for(int j = 0; j < n; j++) out[i][j] = mul(out[i][j], coeff);
			for(int j = 0; j < n; j++) {
				if (j == i) continue;
				elem_t mp = A[j][i];
				for(int k = 0; k < n; k++) A  [j][k] = sub(A  [j][k], mul(A  [i][k], mp));
				for(int k = 0; k < n; k++) out[j][k] = sub(out[j][k], mul(out[i][k], mp));
			}
		}
		return true;
	}
};

int n,m,k;
double weight[500][500];
double allmat[500][500], invmat[500][500];
int trap[500];
vector<int> traps;
double traptrans[101][101], res[101][101];
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i = 0; i < n; i++) {
		scanf("%d",&trap[i]);
		if (trap[i]) {
			traps.push_back(i);
		}
	}
	for(int i = 0; i < m; i++) {
		int a,b;
		scanf("%d%d",&a,&b);
		a--,b--;
		weight[a][b]++;
		weight[b][a]++;
	}
	for(int i = 0; i < n; i++) {
		double allcnt = accumulate(weight[i], weight[i]+n, 0.0);
		for(int j = 0; j < n; j++) {
			weight[i][j] /= allcnt;
		}
		allmat[i][i] += 1.0;
		if (trap[i] == 0) {
			for(int j = 0; j < n; j++) {
				allmat[i][j] -= weight[i][j];
			}
		}
	}
	SqMatrix<double> sq;
	sq.Inverse(n, invmat, allmat);
	int ti = 0;
	for(int i : traps) {
		int tj = 0;
		for(int j : traps) {
			double trans = 0;
			for(int k = 0; k < n; k++) trans += weight[i][k] * invmat[k][j];
			traptrans[ti][tj] = trans;
			tj++;
		}
		ti++;
	}
	sq.Power(traps.size(), res, traptrans, k-2);
	double ans = 0;
	for(int i = 0; i < traps.size(); i++)
	{
		int next = traps[i];
		ans += invmat[0][next] * res[i][traps.size()-1];
	}
	printf("%.10f\n", ans);

	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define mk make_pair
#define pb push_back
#define pa pair<int,int>
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<"\n"
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-') w=-1;ch=getchar();} while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();} return w*s;}
int n,m,k,opt[10100];
struct node{double M[550][550];}trs,tmp;int Map[555][555],du[555],cnt,Idx[555];double Fir[555][555];
inline node operator * (node p,node q){
	node res;
	memset(res.M,0,sizeof(res.M));
	for(rint i=1;i<=cnt;++i)
	for(rint j=1;j<=cnt;++j)
	for(rint k=1;k<=cnt;++k)
	res.M[i][j]+=p.M[i][k]*q.M[k][j];
	return res;
}
inline node ksm(node x,int y){
	node res;memset(res.M,0,sizeof(res.M));
	for(rint i=1;i<=cnt;++i) res.M[i][i]=1;
	while(y){
		if(y&1) res=res*x;
		x=x*x;y>>=1;
	}return res;
}
struct data{int op,a,b;double c;} Sta[1010010];int top;
inline void Gauss(){
	for(rint i=1;i<=n;++i){
		double o=trs.M[i][i];
		for(rint j=i;j<=n;++j) trs.M[i][j]/=o;
		Sta[++top]=(data){0,1,i,o};
		for(rint j=1;j<=n;++j){
			if(i==j) continue;
			double K=trs.M[j][i];
			for(rint t=i;t<=n;++t) trs.M[j][t]-=trs.M[i][t]*K;
			Sta[++top]=(data){1,i,j,K};
		}
	}
//	for(rint i=1;i<=n;++i
}
int main(){
	n=read(),m=read(),k=read();

	for(rint i=1;i<=n;++i) opt[i]=read();
	for(rint i=1;i<=m;++i){
		int x=read(),y=read();
		du[x]++;du[y]++;
		Map[x][y]++;Map[y][x]++;
	}
	for(rint i=1;i<=n;++i){
		for(rint j=1;j<=n;++j){
			if(Map[i][j]&&(!opt[j]))
			trs.M[i][j]=(double)Map[i][j]/du[i];
		}
	}
	for(rint i=1;i<=n;++i) trs.M[i][i]=-1;
//		for(rint i=1;i<=n;++i,cout<<endl) for(rint j=1;j<=n;++j) cout<<trs.M[i][j]<<" ";
	Gauss();//		for(rint i=1;i<=n;++i,cout<<endl) for(rint j=1;j<=n;++j) cout<<trs.M[i][j]<<" ";

	for(rint i=1;i<=n;++i){
		if(!opt[i]) continue;
//		debug(i);
		for(rint j=1;j<=n;++j)// if(Map[j][i])
		{
			Fir[j][i]=(double)-1.0*Map[j][i]/du[j];
//			cout<<Map[j][i]<<" "<<du[j]<<"\n";
//			cout<<Map[j][i]/du[j]<<"\n";
//			cout<<j<<" "<<Fir[j][i]<<"\n";
		}
		for(rint j=1;j<=top;++j){
			if(Sta[j].op)
			{
				int a=Sta[j].a,b=Sta[j].b;double c=Sta[j].c;
				Fir[b][i]-=Fir[a][i]*c;
			}
			else Fir[Sta[j].b][i]/=Sta[j].c;
		}
//		for(rint j=1;j<=n;++j) cout<<Fir[j][i]<<"\n";
//		for(rint j=1;j<=n;++j) Fir[j][i]/=trs.M[j][j];
	}
//	for(rint i=1;i<=n;++i,cout<<endl) for(rint j=1;j<=n;++j) cout<<Fir[i][j]<<" ";
	for(rint i=1;i<=n;++i) if(opt[i]) Idx[++cnt]=i;
	for(rint i=1;i<=cnt;++i) for(rint j=1;j<=cnt;++j) tmp.M[i][j]=Fir[Idx[i]][Idx[j]];
	node o=ksm(tmp,k-2);
	double Ans=0;
	for(rint i=1;i<=cnt;++i) Ans+=Fir[1][Idx[i]]*o.M[i][cnt];
	printf("%.10lf",Ans);
	return 0;
}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define double long double
#define eps 1e-10
#define abs(_o) ((_o<0)?-(_o):(_o))
using namespace std;
namespace ywy{
	inline int get(){
		int n=0;char c;while((c=getchar())||23333){
			if(c>='0'&&c<='9')break;if(c=='-')goto s;
		}n=c-'0';while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10+c-'0';else return(n);
		}s:while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10-c+'0';else return(n);
		}
	}int sz;
	typedef struct _vector{
		double vec[111];_vector(){memset(vec,0,sizeof(vec));}
		friend _vector operator +(const _vector &a,const _vector &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]+=b.vec[i];return(c);
		}
		friend _vector operator -(const _vector &a,const _vector &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]-=b.vec[i];return(c);
		}
		friend _vector operator *(const _vector &a,const double &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]*=b;return(c);
		}
		friend _vector operator /(const _vector &a,const double &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]/=b;return(c);
		}
	}vector;double v[666][666];vector vec[666];int n;
	typedef struct _mx{
		double v[166][166];_mx(){memset(v,0,sizeof(v));}
		friend _mx operator *(const _mx &a,const _mx &b){
			_mx c;for(register int i=0;i<=sz;i++){
				for(register int k=0;k<=sz;k++){
					for(register int j=0;j<=sz;j++)c.v[i][j]+=a.v[i][k]*b.v[k][j];
				}
			}return(c);
		}
	}mx;unsigned char trap[655];
	inline mx mi(mx &a,int b){
		mx ans,tmp=a;for(register int i=0;i<=sz;i++)ans.v[i][i]=1;while(b){
			if(b&1)ans=ans*tmp;tmp=tmp*tmp;b>>=1;
		}return(ans);
	}int deg[555];int g[555][555],lxl[555],fan[555];int xs[666];
	void ywymain(){
		n=get();int m=get(),k=get();for(register int i=1;i<=n;i++)sz+=(trap[i]=get());for(register int i=1;i<=m;i++){
			int s=get(),t=get();deg[s]++;deg[t]++;g[s][t]++;g[t][s]++;
		}int ptr=1;for(register int i=1;i<=n;i++)if(trap[i])lxl[ptr]=i,fan[i]=ptr,ptr++;ptr--;
		for(register int i=1;i<=n;i++){
			v[i][i]=-1;for(register int j=1;j<=n;j++){
				if(trap[j])v[i][fan[j]+n]+=g[i][j]/(double)deg[i];else v[i][j]+=g[i][j]/(double)deg[i];
			}
		}for(register int i=1;i<=ptr;i++){
			vec[i+n].vec[i]=1;v[i+n][i+n]=1;
		}for(register int i=1;i<=n+ptr;i++){
			int me=-1;double mx=0;for(register int j=1;j<=n+ptr;j++)if(abs(v[i][j])>mx)mx=abs(v[i][j]),me=j;
			if(me==-1||abs(mx)<eps)continue;xs[i]=me;double cjr=v[i][me];
			for(register int j=1;j<=n+ptr;j++)v[i][j]/=cjr;vec[i]=vec[i]/cjr;for(register int j=1;j<=n+ptr;j++){
				if(j==i||abs(v[j][me])<eps)continue;double cjr=v[j][me];
				for(register int k=1;k<=n+ptr;k++)v[j][k]-=v[i][k]*cjr;vec[j]=vec[j]-vec[i]*cjr;
			}
		}mx dk;for(register int i=1;i<=n+ptr;i++){
			if((xs[i]<=n&&trap[xs[i]])||xs[i]==1){
				if(xs[i]==1){
					for(register int j=1;j<=ptr;j++)dk.v[0][j]=vec[i].vec[j];
				}else for(register int j=1;j<=ptr;j++)dk.v[fan[xs[i]]][j]=vec[i].vec[j];
			}
		}mx res=mi(dk,k-1);printf("%.10Lf\n",res.v[0][fan[n]]);
	}
}
int main(){
	ywy::ywymain();return(0);
}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define double long double
#define eps 1e-10
#define abs(_o) ((_o<0)?-(_o):(_o))
using namespace std;
namespace ywy{
	inline int get(){
		int n=0;char c;while((c=getchar())||23333){
			if(c>='0'&&c<='9')break;if(c=='-')goto s;
		}n=c-'0';while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10+c-'0';else return(n);
		}s:while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10-c+'0';else return(n);
		}
	}int sz;
	typedef struct _vector{
		double vec[111];_vector(){memset(vec,0,sizeof(vec));}
		friend _vector operator +(const _vector &a,const _vector &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]+=b.vec[i];return(c);
		}
		friend _vector operator -(const _vector &a,const _vector &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]-=b.vec[i];return(c);
		}
		friend _vector operator *(const _vector &a,const double &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]*=b;return(c);
		}
		friend _vector operator /(const _vector &a,const double &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]/=b;return(c);
		}
	}vector;double v[666][666];vector vec[666];int n;
	typedef struct _mx{
		double v[166][166];_mx(){memset(v,0,sizeof(v));}
		friend _mx operator *(const _mx &a,const _mx &b){
			_mx c;for(register int i=0;i<=sz;i++){
				for(register int k=0;k<=sz;k++){
					for(register int j=0;j<=sz;j++)c.v[i][j]+=a.v[i][k]*b.v[k][j];
				}
			}return(c);
		}
	}mx;unsigned char trap[655];
	inline mx mi(mx &a,int b){
		mx ans,tmp=a;for(register int i=0;i<=sz;i++)ans.v[i][i]=1;while(b){
			if(b&1)ans=ans*tmp;tmp=tmp*tmp;b>>=1;
		}return(ans);
	}int deg[555];int g[555][555],lxl[555],fan[555];int xs[666];
	void ywymain(){
		n=get();int m=get(),k=get();for(register int i=1;i<=n;i++)sz+=(trap[i]=get());for(register int i=1;i<=m;i++){
			int s=get(),t=get();deg[s]++;deg[t]++;g[s][t]++;g[t][s]++;
		}int ptr=1;for(register int i=1;i<=n;i++)if(trap[i])lxl[ptr]=i,fan[i]=ptr,ptr++;ptr--;
		for(register int i=1;i<=n;i++){
			v[i][i]=-1;for(register int j=1;j<=n;j++){
				if(trap[j])v[i][fan[j]+n]+=g[i][j]/(double)deg[i];else v[i][j]+=g[i][j]/(double)deg[i];
			}
		}for(register int i=1;i<=ptr;i++){
			vec[i+n].vec[i]=1;v[i+n][i+n]=1;
		}for(register int i=1;i<=n+ptr;i++){
			int me=-1;double mx=0;for(register int j=1;j<=n+ptr;j++)if(abs(v[i][j])>mx)mx=abs(v[i][j]),me=j;
			if(me==-1||abs(mx)<eps)continue;xs[i]=me;double cjr=v[i][me];
			for(register int j=1;j<=n+ptr;j++)v[i][j]/=cjr;vec[i]=vec[i]/cjr;for(register int j=1;j<=n+ptr;j++){
				if(j==i||abs(v[j][me])<eps)continue;double cjr=v[j][me];
				for(register int k=1;k<=n+ptr;k++)v[j][k]-=v[i][k]*cjr;vec[j]=vec[j]-vec[i]*cjr;
			}
		}mx dk;for(register int i=1;i<=n+ptr;i++){
			if((xs[i]<=n&&trap[xs[i]])||xs[i]==1){
				if(xs[i]==1){
					for(register int j=1;j<=ptr;j++)dk.v[0][j]=vec[i].vec[j];
				}else for(register int j=1;j<=ptr;j++)dk.v[fan[xs[i]]][j]=vec[i].vec[j];
			}
		}mx res=mi(dk,k-1);printf("%.4lf\n",res.v[0][fan[n]]);
	}
}
int main(){
	ywy::ywymain();return(0);
}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define eps 1e-8
#define abs(_o) ((_o<0)?-(_o):(_o))
using namespace std;
namespace ywy{
	inline int get(){
		int n=0;char c;while((c=getchar())||23333){
			if(c>='0'&&c<='9')break;if(c=='-')goto s;
		}n=c-'0';while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10+c-'0';else return(n);
		}s:while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10-c+'0';else return(n);
		}
	}int sz;
	typedef struct _vector{
		double vec[111];_vector(){memset(vec,0,sizeof(vec));}
		friend _vector operator +(const _vector &a,const _vector &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]+=b.vec[i];return(c);
		}
		friend _vector operator -(const _vector &a,const _vector &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]-=b.vec[i];return(c);
		}
		friend _vector operator *(const _vector &a,const double &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]*=b;return(c);
		}
		friend _vector operator /(const _vector &a,const double &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]/=b;return(c);
		}
	}vector;double v[666][666];vector vec[666];int n;
	typedef struct _mx{
		double v[166][166];_mx(){memset(v,0,sizeof(v));}
		friend _mx operator *(const _mx &a,const _mx &b){
			_mx c;for(register int i=0;i<=sz;i++){
				for(register int k=0;k<=sz;k++){
					for(register int j=0;j<=sz;j++)c.v[i][j]+=a.v[i][k]*b.v[k][j];
				}
			}return(c);
		}
	}mx;unsigned char trap[655];
	inline mx mi(mx &a,int b){
		mx ans,tmp=a;for(register int i=0;i<=sz;i++)ans.v[i][i]=1;while(b){
			if(b&1)ans=ans*tmp;tmp=tmp*tmp;b>>=1;
		}return(ans);
	}int deg[555];int g[555][555],lxl[555],fan[555];int xs[666];
	void ywymain(){
		n=get();int m=get(),k=get();for(register int i=1;i<=n;i++)sz+=(trap[i]=get());for(register int i=1;i<=m;i++){
			int s=get(),t=get();deg[s]++;deg[t]++;g[s][t]++;g[t][s]++;
		}int ptr=1;for(register int i=1;i<=n;i++)if(trap[i])lxl[ptr]=i,fan[i]=ptr,ptr++;ptr--;
		for(register int i=1;i<=n;i++){
			v[i][i]=-1;for(register int j=1;j<=n;j++){
				if(trap[j])v[i][fan[j]+n]+=g[i][j]/(double)deg[i];else v[i][j]+=g[i][j]/(double)deg[i];
			}
		}for(register int i=1;i<=ptr;i++){
			vec[i+n].vec[i]=1;v[i+n][i+n]=1;
		}for(register int i=1;i<=n+ptr;i++){
			int me=-1;double mx=0;for(register int j=1;j<=n+ptr;j++)if(abs(v[i][j])>mx)mx=abs(v[i][j]),me=j;
			if(me==-1||abs(mx)<eps)continue;xs[i]=me;double cjr=v[i][me];
			for(register int j=1;j<=n+ptr;j++)v[i][j]/=cjr;vec[i]=vec[i]/cjr;for(register int j=1;j<=n+ptr;j++){
				if(j==i||abs(v[j][me])<eps)continue;double cjr=v[j][me];
				for(register int k=1;k<=n+ptr;k++)v[j][k]-=v[i][k]*cjr;vec[j]=vec[j]-vec[i]*cjr;
			}
		}mx dk;for(register int i=1;i<=n+ptr;i++){
			if((xs[i]<=n&&trap[xs[i]])||xs[i]==1){
				if(xs[i]==1){
					for(register int j=1;j<=ptr;j++)dk.v[0][j]=vec[i].vec[j];
				}else for(register int j=1;j<=ptr;j++)dk.v[fan[xs[i]]][j]=vec[i].vec[j];
			}
		}mx res=mi(dk,k-1);printf("%.4lf\n",res.v[0][fan[n]]);
	}
}
int main(){
	ywy::ywymain();return(0);
}


#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define eps 1e-10
#define abs(_o) ((_o<0)?-(_o):(_o))
using namespace std;
namespace ywy{
	inline int get(){
		int n=0;char c;while((c=getchar())||23333){
			if(c>='0'&&c<='9')break;if(c=='-')goto s;
		}n=c-'0';while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10+c-'0';else return(n);
		}s:while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10-c+'0';else return(n);
		}
	}int sz;
	typedef struct _vector{
		double vec[111];_vector(){memset(vec,0,sizeof(vec));}
		friend _vector operator +(const _vector &a,const _vector &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]+=b.vec[i];return(c);
		}
		friend _vector operator -(const _vector &a,const _vector &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]-=b.vec[i];return(c);
		}
		friend _vector operator *(const _vector &a,const double &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]*=b;return(c);
		}
		friend _vector operator /(const _vector &a,const double &b){
			_vector c=a;for(register int i=1;i<=sz;i++)c.vec[i]/=b;return(c);
		}
	}vector;double v[666][666];vector vec[666];int n;
	typedef struct _mx{
		double v[166][166];_mx(){memset(v,0,sizeof(v));}
		friend _mx operator *(const _mx &a,const _mx &b){
			_mx c;for(register int i=0;i<=sz;i++){
				for(register int k=0;k<=sz;k++){
					for(register int j=0;j<=sz;j++)c.v[i][j]+=a.v[i][k]*b.v[k][j];
				}
			}return(c);
		}
	}mx;unsigned char trap[655];
	inline mx mi(mx &a,int b){
		mx ans,tmp=a;for(register int i=0;i<=sz;i++)ans.v[i][i]=1;while(b){
			if(b&1)ans=ans*tmp;tmp=tmp*tmp;b>>=1;
		}return(ans);
	}int deg[555];int g[555][555],lxl[555],fan[555];int xs[666];
	void ywymain(){
		n=get();int m=get(),k=get();for(register int i=1;i<=n;i++)sz+=(trap[i]=get());for(register int i=1;i<=m;i++){
			int s=get(),t=get();deg[s]++;deg[t]++;g[s][t]++;g[t][s]++;
		}int ptr=1;for(register int i=1;i<=n;i++)if(trap[i])lxl[ptr]=i,fan[i]=ptr,ptr++;ptr--;
		for(register int i=1;i<=n;i++){
			v[i][i]=-1;for(register int j=1;j<=n;j++){
				if(trap[j])v[i][fan[j]+n]+=g[i][j]/(double)deg[i];else v[i][j]+=g[i][j]/(double)deg[i];
			}
		}for(register int i=1;i<=ptr;i++){
			vec[i+n].vec[i]=1;v[i+n][i+n]=1;
		}for(register int i=1;i<=n+ptr;i++){
			int me=-1;double mx=0;for(register int j=1;j<=n+ptr;j++)if(abs(v[i][j])>mx)mx=abs(v[i][j]),me=j;
			if(me==-1||abs(mx)<eps)continue;xs[i]=me;double cjr=v[i][me];
			for(register int j=1;j<=n+ptr;j++)v[i][j]/=cjr;vec[i]=vec[i]/cjr;for(register int j=1;j<=n+ptr;j++){
				if(j==i||abs(v[j][me])<eps)continue;double cjr=v[j][me];
				for(register int k=1;k<=n+ptr;k++)v[j][k]-=v[i][k]*cjr;vec[j]=vec[j]-vec[i]*cjr;
			}
		}mx dk;for(register int i=1;i<=n+ptr;i++){
			if((xs[i]<=n&&trap[xs[i]])||xs[i]==1){
				if(xs[i]==1){
					for(register int j=1;j<=ptr;j++)dk.v[0][j]=vec[i].vec[j];
				}else for(register int j=1;j<=ptr;j++)dk.v[fan[xs[i]]][j]=vec[i].vec[j];
			}
		}mx res=mi(dk,k-1);printf("%.10lf\n",res.v[0][fan[n]]);
	}
}
int main(){
	ywy::ywymain();return(0);
}


#include <bits/stdc++.h>
using namespace std;
const int N=505;
int tot;
struct matrix{
	double a[N][N];
	matrix(){memset(a,0,sizeof(a));}
	double*operator[](int x){return a[x];}
	matrix operator*(matrix b){
		matrix ret;
		for(int i=1;i<=tot;i++)
			for(int k=1;k<=tot;k++)
				for(int j=1;j<=tot;j++)
					ret[i][j]+=a[i][k]*b[k][j];
		return ret;
	}
	matrix operator^(int k){
		matrix ret,x=*this;
		for(int i=1;i<=tot;i++)ret[i][i]=1;
		while(k){
			if(k&1)ret=ret*x;
			k>>=1;x=x*x;
		}
		return ret;
	}
	matrix inv(){
		matrix A=*this,B;
		for(int i=1;i<=tot;i++)B[i][i]=1;
		for(int i=1;i<=tot;i++){
			int now=i;
			while(now<=tot&&!A[now][i])now++;
			if(now!=i)swap(A.a[now],A.a[i]),swap(B.a[now],B.a[i]);
			double tmp=A[i][i];
			for(int j=1;j<=tot;j++)A[i][j]/=tmp,B[i][j]/=tmp;
			for(int j=1;j<=tot;j++){
				if(i==j)continue;
				tmp=A[j][i];
				for(int k=1;k<=tot;k++)A[j][k]-=A[i][k]*tmp,B[j][k]-=B[i][k]*tmp;
			}
		}
		return B;
	}
}a,b;
int n,m,K,trap[N];
vector<int>G[N];
double g[N][N];
int main(){
	scanf("%d%d%d",&n,&m,&K);
	for(int i=1;i<=n;i++)scanf("%d",&trap[i]);
	for(int i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);
		G[x].push_back(y);G[y].push_back(x);
	}
	tot=n;
	for(int i=1;i<=n;i++){
		a[i][i]=1;
		if(trap[i])continue;
		double p=1.0/G[i].size();
		for(int j=0;j<G[i].size();j++){
			int k=G[i][j];
			if(trap[k])continue;
			a[i][k]+=-p;
		}
	}
	a=a.inv();
	for(int st=1;st<=n;st++){
		if(trap[st]){g[st][st]=1;continue;}
		for(int i=1;i<=n;i++){
			for(int j=0;j<G[i].size();j++){
				int k=G[i][j];
				if(trap[k])g[st][k]+=a[i][st]/G[i].size();
			}
		}
	}
	for(int i=1;i<=n;i++){
		double p=1.0/G[i].size();
		for(int j=0;j<G[i].size();j++){
			int k=G[i][j];
			for(int t=1;t<=n;t++)
			b[i][t]+=p*g[k][t];
		}
	}
	b=b^(K-1);
	matrix st;
	st[1][1]=1;
	tot=n;
	st=st*b;
	printf("%.4f\n",st[1][n]);
}


#include <bits/stdc++.h>
using namespace std;
const int N=505;
int tot;
struct matrix{
	double a[N][N];
	matrix(){memset(a,0,sizeof(a));}
	double*operator[](int x){return a[x];}
	matrix operator*(matrix b){
		matrix ret;
		for(int i=1;i<=tot;i++)
			for(int k=1;k<=tot;k++)
				for(int j=1;j<=tot;j++)
					ret[i][j]+=a[i][k]*b[k][j];
		return ret;
	}
	matrix operator^(int k){
		matrix ret,x=*this;
		for(int i=1;i<=tot;i++)ret[i][i]=1;
		while(k){
			if(k&1)ret=ret*x;
			k>>=1;x=x*x;
		}
		return ret;
	}
	matrix inv(){
		matrix A=*this,B;
		for(int i=1;i<=tot;i++)B[i][i]=1;
		for(int i=1;i<=tot;i++){
			int now=i;
			while(now<=tot&&!A[now][i])now++;
			if(now!=i)swap(A.a[now],A.a[i]),swap(B.a[now],B.a[i]);
			double tmp=A[i][i];
			for(int j=1;j<=tot;j++)A[i][j]/=tmp,B[i][j]/=tmp;
			for(int j=1;j<=tot;j++){
				if(i==j)continue;
				tmp=A[j][i];
				for(int k=1;k<=tot;k++)A[j][k]-=A[i][k]*tmp,B[j][k]-=B[i][k]*tmp;
			}
		}
		return B;
	}
}a,b;
int n,m,K,trap[N],mp[N][N],d[N];
double g[N][N];
int main(){
	scanf("%d%d%d",&n,&m,&K);
	for(int i=1;i<=n;i++)scanf("%d",&trap[i]);
	for(int i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);
		mp[x][y]++;mp[y][x]++;
		d[x]++;d[y]++;
	}
	tot=n;
	for(int i=1;i<=n;i++){
		a[i][i]=1;
		for(int j=1;j<=n;j++)if(!trap[j])a[i][j]-=1.0*mp[i][j]/d[i];
	}
	a=a.inv();
	for(int st=1;st<=n;st++){
		if(!trap[st])continue;
		static double tmp[N];
		memset(tmp,0,sizeof(tmp));
		for(int j=1;j<=n;j++)tmp[j]+=1.0*mp[j][st]/d[j];
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				g[i][st]+=a[i][j]*tmp[j];
	}
	memcpy(b.a,g,sizeof(g));
	b=b^(K-1);
	matrix st;
	st[1][1]=1;
	tot=n;
	st=st*b;
	printf("%.4f\n",st[1][n]);
}
/*
15 51 15151
0 0 1 1 1 0 0 0 0 1 0 0 1 1 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
14 7
6 13
3 4
12 7
3 13
6 2
13 4
11 10
14 2
11 9
7 5
11 13
7 2
15 3
5 11
2 3
3 1
15 7
3 15
15 2
2 11
5 11
1 2
11 12
1 13
3 12
12 6
11 1
5 2
13 9
1 11
11 14
14 9
4 1
2 3
4 9
5 8
*/


#include <bits/stdc++.h>
using namespace std;
const int N=505;
int tot;
struct matrix{
	double a[N][N];
	matrix(){memset(a,0,sizeof(a));}
	double*operator[](int x){return a[x];}
	matrix operator*(matrix b){
		matrix ret;
		for(int i=1;i<=tot;i++)
			for(int k=1;k<=tot;k++)
				for(int j=1;j<=tot;j++)
					ret[i][j]+=a[i][k]*b[k][j];
		return ret;
	}
	matrix operator^(int k){
		matrix ret,x=*this;
		for(int i=1;i<=tot;i++)ret[i][i]=1;
		while(k){
			if(k&1)ret=ret*x;
			k>>=1;x=x*x;
		}
		return ret;
	}
	matrix inv(){
		matrix A=*this,B;
		for(int i=1;i<=tot;i++)B[i][i]=1;
		for(int i=1;i<=tot;i++){
			int now=i;
			while(now<=tot&&!A[now][i])now++;
			if(now!=i)swap(A.a[now],A.a[i]),swap(B.a[now],B.a[i]);
			double tmp=A[i][i];
			for(int j=1;j<=tot;j++)A[i][j]/=tmp,B[i][j]/=tmp;
			for(int j=1;j<=tot;j++){
				if(i==j)continue;
				tmp=A[j][i];
				for(int k=1;k<=tot;k++)A[j][k]-=A[i][k]*tmp,B[j][k]-=B[i][k]*tmp;
			}
		}
		return B;
	}
}a,b;
int n,m,K,trap[N],mp[N][N],d[N];
double g[N][N];
int main(){
	scanf("%d%d%d",&n,&m,&K);
	for(int i=1;i<=n;i++)scanf("%d",&trap[i]);
	for(int i=1;i<=m;i++){
		int x,y;scanf("%d%d",&x,&y);
		mp[x][y]++;mp[y][x]++;
		d[x]++;d[y]++;
	}
	tot=n;
	for(int i=1;i<=n;i++){
		a[i][i]=1;
		for(int j=1;j<=n;j++)if(!trap[j])a[i][j]-=1.0*mp[i][j]/d[i];
	}
	a=a.inv();
	for(int st=1;st<=n;st++){
		if(!trap[st])continue;
		static double tmp[N];
		memset(tmp,0,sizeof(tmp));
		for(int j=1;j<=n;j++)tmp[j]+=1.0*mp[j][st]/d[j];
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				g[i][st]+=a[i][j]*tmp[j];
	}
	tot=0;
	int id[N];
	for(int i=1;i<=n;i++)if(i==1||trap[i])id[++tot]=i;
	for(int i=1;i<=tot;i++)
		for(int j=1;j<=tot;j++)
			b[i][j]=g[id[i]][id[j]];
	b=b^(K-1);
	matrix st;
	st[1][1]=1;
	st=st*b;
	printf("%.4f\n",st[1][tot]);
}
/*
15 51 15151
0 0 1 1 1 0 0 0 0 1 0 0 1 1 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
14 7
6 13
3 4
12 7
3 13
6 2
13 4
11 10
14 2
11 9
7 5
11 13
7 2
15 3
5 11
2 3
3 1
15 7
3 15
15 2
2 11
5 11
1 2
11 12
1 13
3 12
12 6
11 1
5 2
13 9
1 11
11 14
14 9
4 1
2 3
4 9
5 8
*/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=505;
#define ld long double
struct matrix{
	ld a[N][N];
	inline ld* operator [] (int x){
        return a[x];
    }
    void clear(){
    	memset(a,0,sizeof(a));
	}
}A,g,ans,b,tmp;
int n,m,k,a[N],B[N];
vector<int> v[N];
matrix inv(matrix a){
	b.clear();
	for(int i=1;i<=n;i++)b[i][i]=1;
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++)if(a[j][i]){
			swap(a.a[i],a.a[j]); swap(b.a[i],b.a[j]); break;
		}
		if(fabs(a[i][i])<1e-12)while(1);
		for(int j=1;j<=n;j++)b[i][j]/=a[i][i];
		for(int j=n;j>=i;j--)a[i][j]/=a[i][i];
		for(int j=1;j<=n;j++)if(i!=j){
			ld t=a[j][i];
			for(int k=1;k<=n;k++)b[j][k]-=t*b[i][k];
			for(int k=1;k<=n;k++){ a[j][k]-=t*a[i][k];}
		}
	}
	//for(int i=1;i<=n;i++){for(int j=1;j<=n;j++)cout<<a[i][j]<<" "; puts("");}

	return b;
}
int tot;
matrix operator *(matrix a,matrix b){
	tmp.clear();
	for(int i=1;i<=tot;i++){
		for(int j=1;j<=tot;j++){
			for(int k=1;k<=tot;k++){
				tmp[i][j]=tmp[i][j]+a[i][k]*b[k][j];
				//cout<<tmp[i][j]<<" "<<i<<" "<<j<<endl;
			}
		}
	}
	return tmp;
}
matrix ksm(matrix ans,matrix a,int k){
	for(;k;k>>=1){
		if(k&1)ans=ans*a;
		a=a*a;
	}
	return ans;
}
int q[N];
int main(){
	n=read(); m=read(); k=read();
	for(int i=1;i<=n;i++){a[i]=read(); if(a[i])q[++tot]=i;}
	for(int i=1;i<=m;i++){
		int s=read(),t=read();
		v[s].push_back(t); v[t].push_back(s);
	}
	for(int i=1;i<=n;i++){
		A[i][i]=1;
		if(a[i]==0)for(auto j:v[i]){
			A[i][j]+=(ld)-1/v[i].size();
		}
	}
	matrix x=inv(A);
	//for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)cout<<x[i][j]<<" "<<i<<" "<<j<<endl;
	for(int i=1;i<=tot;i++)for(int j=1;j<=tot;j++){
		for(auto k:v[q[i]])g[i][j]+=x[k][q[j]]; g[i][j]/=v[q[i]].size();//cout<<g[i][j]<<" wzp "<<i<<" "<<j<<endl;
	}
	for(int i=1;i<=tot;i++)ans[1][i]=x[1][q[i]];
	//for(int i=1;i<=tot;i++)for(int j=1;j<=tot;j++)cout<<ans[i][j]<<" wzp "<<g[i][j]<<endl;
	matrix t=ksm(ans,g,k-2);
	printf("%.5lf\n",(double)t[1][tot]);
}
/*
if(!...)f[i]=0
else f[i]=1
f[i]=(sigma f[j])/rd[i]
*/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=505;
#define ld double
struct matrix{
	ld a[N][N];
	inline ld* operator [] (int x){
        return a[x];
    }
    void clear(){
    	memset(a,0,sizeof(a));
	}
}A,g,ans,b,tmp;
int n,m,k,a[N],B[N];
vector<int> v[N];
matrix inv(matrix a){
	b.clear();
	for(int i=1;i<=n;i++)b[i][i]=1;
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++)if(a[j][i]){
			swap(a.a[i],a.a[j]); swap(b.a[i],b.a[j]); break;
		}
		if(fabs(a[i][i])<1e-12)while(1);
		for(int j=1;j<=n;j++)b[i][j]/=a[i][i];
		for(int j=n;j>=i;j--)a[i][j]/=a[i][i];
		for(int j=1;j<=n;j++)if(i!=j){
			ld t=a[j][i];
			for(int k=1;k<=n;k++)b[j][k]-=t*b[i][k];
			for(int k=1;k<=n;k++){ a[j][k]-=t*a[i][k];}
		}
	}
	//for(int i=1;i<=n;i++){for(int j=1;j<=n;j++)cout<<a[i][j]<<" "; puts("");}

	return b;
}
int tot;
matrix operator *(matrix a,matrix b){
	tmp.clear();
	for(int i=1;i<=tot;i++){
		for(int j=1;j<=tot;j++){
			for(int k=1;k<=tot;k++){
				tmp[i][j]=tmp[i][j]+a[i][k]*b[k][j];
				//cout<<tmp[i][j]<<" "<<i<<" "<<j<<endl;
			}
		}
	}
	return tmp;
}
matrix ksm(matrix ans,matrix a,int k){
	for(;k;k>>=1){
		if(k&1)ans=ans*a;
		a=a*a;
	}
	return ans;
}
int q[N];
int main(){
	n=read(); m=read(); k=read();
	for(int i=1;i<=n;i++){a[i]=read(); if(a[i])q[++tot]=i;}
	for(int i=1;i<=m;i++){
		int s=read(),t=read();
		v[s].push_back(t); v[t].push_back(s);
	}
	for(int i=1;i<=n;i++){
		A[i][i]=1;
		if(a[i]==0)for(auto j:v[i]){
			A[i][j]+=(ld)-1/v[i].size();
		}
	}
	matrix x=inv(A);
	//for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)cout<<x[i][j]<<" "<<i<<" "<<j<<endl;
	for(int i=1;i<=tot;i++)for(int j=1;j<=tot;j++){
		for(auto k:v[q[i]])g[i][j]+=x[k][q[j]]; g[i][j]/=v[q[i]].size();//cout<<g[i][j]<<" wzp "<<i<<" "<<j<<endl;
	}
	for(int i=1;i<=tot;i++)ans[1][i]=x[1][q[i]];
	//for(int i=1;i<=tot;i++)for(int j=1;j<=tot;j++)cout<<ans[i][j]<<" wzp "<<g[i][j]<<endl;
	matrix t=ksm(ans,g,k-2);
	printf("%.5lf\n",(double)t[1][tot]);
}
/*
if(!...)f[i]=0
else f[i]=1
f[i]=(sigma f[j])/rd[i]
*/