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

public class Main {

	public static void main(String[] args) {
		// 初期化
		FastScanner sc = new FastScanner(System.in);
        PrintWriter printWriter = new PrintWriter(System.out);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String[] moji_data = sc.next().split("");
		int result_cnt=0;
		int[] ruiseki_data= new int[moji_data.length];

		// 文字列に含まれるACの数を累積和でカウントする。
		for(int i=0;i<moji_data.length-1;i++) {
			if(moji_data[i].equals("A") && moji_data[i+1].equals("C")) {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			}
			else {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			}
		}
		for(int i=0;i<q;i++) {
			// 開始位置、終了位置の取得
			int start = sc.nextInt();
			int end = sc.nextInt();
			// 開始位置から終了位置までのACの数を取得する。
	        printWriter.printf("%d\n", ruiseki_data[end-1] - ruiseki_data[start-1]);
		}
        printWriter.close();
	}

	static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

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

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public double nextDouble() {
             return Double.parseDouble(next());
         }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {

	public static void main(String[] args) {
		// 初期化
		FastScanner sc = new FastScanner(System.in);
        PrintWriter printWriter = new PrintWriter(System.out);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String[] moji_data = sc.next().split("");
		int result_cnt=0;
		int[] ruiseki_data= new int[moji_data.length];

		// 文字列に含まれるACの数を累積和でカウントする。
		for(int i=0;i<moji_data.length-1;i++) {
			if(moji_data[i].equals("A") && moji_data[i+1].equals("C")) {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			}
			else {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			}
		}
		for(int i=0;i<q;i++) {
			// 開始位置、終了位置の取得
			int start = sc.nextInt();
			int end = sc.nextInt();
			// 開始位置から終了位置までのACの数を取得する。
	        printWriter.printf("%d\n", ruiseki_data[end-1] - ruiseki_data[start-1]);
		}
        printWriter.close();
	}

	static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

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

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public double nextDouble() {
             return Double.parseDouble(next());
         }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
} Main public static void main(String[] args) {
		// 初期化
		FastScanner sc = new FastScanner(System.in);
        PrintWriter printWriter = new PrintWriter(System.out);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String[] moji_data = sc.next().split("");
		int result_cnt=0;
		int[] ruiseki_data= new int[moji_data.length];

		// 文字列に含まれるACの数を累積和でカウントする。
		for(int i=0;i<moji_data.length-1;i++) {
			if(moji_data[i].equals("A") && moji_data[i+1].equals("C")) {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			}
			else {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			}
		}
		for(int i=0;i<q;i++) {
			// 開始位置、終了位置の取得
			int start = sc.nextInt();
			int end = sc.nextInt();
			// 開始位置から終了位置までのACの数を取得する。
	        printWriter.printf("%d\n", ruiseki_data[end-1] - ruiseki_data[start-1]);
		}
        printWriter.close();
	} main {
		// 初期化
		FastScanner sc = new FastScanner(System.in);
        PrintWriter printWriter = new PrintWriter(System.out);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String[] moji_data = sc.next().split("");
		int result_cnt=0;
		int[] ruiseki_data= new int[moji_data.length];

		// 文字列に含まれるACの数を累積和でカウントする。
		for(int i=0;i<moji_data.length-1;i++) {
			if(moji_data[i].equals("A") && moji_data[i+1].equals("C")) {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			}
			else {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			}
		}
		for(int i=0;i<q;i++) {
			// 開始位置、終了位置の取得
			int start = sc.nextInt();
			int end = sc.nextInt();
			// 開始位置から終了位置までのACの数を取得する。
	        printWriter.printf("%d\n", ruiseki_data[end-1] - ruiseki_data[start-1]);
		}
        printWriter.close();
	} FastScanner sc = new FastScanner(System.in); sc new FastScanner(System.in) PrintWriter printWriter = new PrintWriter(System.out); printWriter new PrintWriter(System.out) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int q = sc.nextInt(); q sc.nextInt() sc.nextInt sc String[] moji_data = sc.next().split(""); moji_data sc.next().split("") sc.next().split sc.next() sc.next sc "" int result_cnt=0; result_cnt 0 int[] ruiseki_data= new int[moji_data.length]; ruiseki_data new int[moji_data.length] moji_data.length moji_data moji_data.length for(int i=0;i<moji_data.length-1;i++) {
			if(moji_data[i].equals("A") && moji_data[i+1].equals("C")) {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			}
			else {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			}
		} int i=0; int i=0; i 0 i<moji_data.length-1 i moji_data.length-1 moji_data.length moji_data moji_data.length 1 i++ i++ i {
			if(moji_data[i].equals("A") && moji_data[i+1].equals("C")) {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			}
			else {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			}
		} {
			if(moji_data[i].equals("A") && moji_data[i+1].equals("C")) {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			}
			else {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			}
		} if(moji_data[i].equals("A") && moji_data[i+1].equals("C")) {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			}
			else {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			} moji_data[i].equals("A") && moji_data[i+1].equals("C") moji_data[i].equals("A") moji_data[i].equals moji_data[i] moji_data i "A" moji_data[i+1].equals("C") moji_data[i+1].equals moji_data[i+1] moji_data i+1 i 1 "C" {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			} ruiseki_data[i+1] = ruiseki_data[i]+1 ruiseki_data[i+1] ruiseki_data i+1 i 1 ruiseki_data[i]+1 ruiseki_data[i] ruiseki_data i 1 {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			} ruiseki_data[i+1] = ruiseki_data[i] ruiseki_data[i+1] ruiseki_data i+1 i 1 ruiseki_data[i] ruiseki_data i for(int i=0;i<q;i++) {
			// 開始位置、終了位置の取得
			int start = sc.nextInt();
			int end = sc.nextInt();
			// 開始位置から終了位置までのACの数を取得する。
	        printWriter.printf("%d\n", ruiseki_data[end-1] - ruiseki_data[start-1]);
		} int i=0; int i=0; i 0 i<q i q i++ i++ i {
			// 開始位置、終了位置の取得
			int start = sc.nextInt();
			int end = sc.nextInt();
			// 開始位置から終了位置までのACの数を取得する。
	        printWriter.printf("%d\n", ruiseki_data[end-1] - ruiseki_data[start-1]);
		} {
			// 開始位置、終了位置の取得
			int start = sc.nextInt();
			int end = sc.nextInt();
			// 開始位置から終了位置までのACの数を取得する。
	        printWriter.printf("%d\n", ruiseki_data[end-1] - ruiseki_data[start-1]);
		} int start = sc.nextInt(); start sc.nextInt() sc.nextInt sc int end = sc.nextInt(); end sc.nextInt() sc.nextInt sc printWriter.printf("%d\n", ruiseki_data[end-1] - ruiseki_data[start-1]) printWriter.printf printWriter "%d\n" ruiseki_data[end-1] - ruiseki_data[start-1] ruiseki_data[end-1] ruiseki_data end-1 end 1 ruiseki_data[start-1] ruiseki_data start-1 start 1 printWriter.close() printWriter.close printWriter String[] args args static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

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

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public double nextDouble() {
             return Double.parseDouble(next());
         }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    } FastScanner private BufferedReader reader = null; reader null private StringTokenizer tokenizer = null; tokenizer null public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        } FastScanner {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        } reader = new BufferedReader(new InputStreamReader(in)) reader new BufferedReader(new InputStreamReader(in)) tokenizer = null tokenizer null InputStream in in public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } next {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        } nextLine {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        } if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    return reader.readLine();
                } return reader.readLine(); reader.readLine() reader.readLine reader return tokenizer.nextToken("\n"); tokenizer.nextToken("\n") tokenizer.nextToken tokenizer "\n" public long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public double nextDouble() {
             return Double.parseDouble(next());
         } nextDouble {
             return Double.parseDouble(next());
         } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        } nextIntArray {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        } int[] a = new int[n]; a new int[n] n for (int i = 0; i < n; i++)
                a[i] = nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = nextInt(); a[i] = nextInt() a[i] a i nextInt() nextInt return a; a int n n public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        } nextLongArray {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        } long[] a = new long[n]; a new long[n] n for (int i = 0; i < n; i++)
                a[i] = nextLong(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = nextLong(); a[i] = nextLong() a[i] a i nextLong() nextLong return a; a int n n public class Main {

	public static void main(String[] args) {
		// 初期化
		FastScanner sc = new FastScanner(System.in);
        PrintWriter printWriter = new PrintWriter(System.out);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String[] moji_data = sc.next().split("");
		int result_cnt=0;
		int[] ruiseki_data= new int[moji_data.length];

		// 文字列に含まれるACの数を累積和でカウントする。
		for(int i=0;i<moji_data.length-1;i++) {
			if(moji_data[i].equals("A") && moji_data[i+1].equals("C")) {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			}
			else {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			}
		}
		for(int i=0;i<q;i++) {
			// 開始位置、終了位置の取得
			int start = sc.nextInt();
			int end = sc.nextInt();
			// 開始位置から終了位置までのACの数を取得する。
	        printWriter.printf("%d\n", ruiseki_data[end-1] - ruiseki_data[start-1]);
		}
        printWriter.close();
	}

	static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

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

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public double nextDouble() {
             return Double.parseDouble(next());
         }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
} public class Main {

	public static void main(String[] args) {
		// 初期化
		FastScanner sc = new FastScanner(System.in);
        PrintWriter printWriter = new PrintWriter(System.out);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String[] moji_data = sc.next().split("");
		int result_cnt=0;
		int[] ruiseki_data= new int[moji_data.length];

		// 文字列に含まれるACの数を累積和でカウントする。
		for(int i=0;i<moji_data.length-1;i++) {
			if(moji_data[i].equals("A") && moji_data[i+1].equals("C")) {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			}
			else {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			}
		}
		for(int i=0;i<q;i++) {
			// 開始位置、終了位置の取得
			int start = sc.nextInt();
			int end = sc.nextInt();
			// 開始位置から終了位置までのACの数を取得する。
	        printWriter.printf("%d\n", ruiseki_data[end-1] - ruiseki_data[start-1]);
		}
        printWriter.close();
	}

	static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

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

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public double nextDouble() {
             return Double.parseDouble(next());
         }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		// 初期化
		FastScanner sc = new FastScanner(System.in);
        PrintWriter printWriter = new PrintWriter(System.out);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String[] moji_data = sc.next().split("");
		int result_cnt=0;
		int[] ruiseki_data= new int[moji_data.length];

		// 文字列に含まれるACの数を累積和でカウントする。
		for(int i=0;i<moji_data.length-1;i++) {
			if(moji_data[i].equals("A") && moji_data[i+1].equals("C")) {
				// Cの箇所に加算する。
				ruiseki_data[i+1] = ruiseki_data[i]+1;
			}
			else {
				ruiseki_data[i+1] = ruiseki_data[i];
				
			}
		}
		for(int i=0;i<q;i++) {
			// 開始位置、終了位置の取得
			int start = sc.nextInt();
			int end = sc.nextInt();
			// 開始位置から終了位置までのACの数を取得する。
	        printWriter.printf("%d\n", ruiseki_data[end-1] - ruiseki_data[start-1]);
		}
        printWriter.close();
	}

	static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

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

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public double nextDouble() {
             return Double.parseDouble(next());
         }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}
