Which type of exception is occurs in this code.
Why the catch statement is not taking ArrayOutofBoundsException e.  
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
    int i,j,k,n,m,l,x,y;
    Scanner sc=new Scanner (System.in);
    n=sc.nextInt();
    ArrayList [] a=new ArrayList[n];
    for(i=0;i<n;i++)
        {
        m=sc.nextInt();
       a[i]=new ArrayList();
        for(j=0;j<m;j++)
        {
            a[i].add(sc.nextInt());
        } 
    }
    k=sc.nextInt();
    for(i=0;i<k;i++)
        {
        x=sc.nextInt();
        y=sc.nextInt();
        try
            {
            System.out.println(a[x-1].get(y-1));
        }
        catch(ArrayOutofBoundsException e)
            {
            System.out.println("ERROR!");
        }
    }
  }
}
 
    