1209: Breed Counting

文件提交:无需freopen 内存限制:250 MB 时间限制:2.000 S
评测方式:普通裁判 命题人:
提交:1 解决:1

题目描述

Farmer John 的 lns="http://www.w3.org/1998/Math/MathML"> 头奶牛,从左到右编号为 lns="http://www.w3.org/1998/Math/MathML">1,排成一队。

所有牛都可以分为三个品种,每头牛都有一个品种编号(只能为 lns="http://www.w3.org/1998/Math/MathML">1,2,3 中的一个)。FJ 有 lns="http://www.w3.org/1998/Math/MathML"> 个询问,每个询问希望求出某个区间内每个品种奶牛的数量。

输入

第一行两个整数 lns="http://www.w3.org/1998/Math/MathML">,lns="http://www.w3.org/1998/Math/MathML">1,105)。

接下来 lns="http://www.w3.org/1998/Math/MathML"> 行,每行一个整数,第 lns="http://www.w3.org/1998/Math/MathML"> 个整数代表第 lns="http://www.w3.org/1998/Math/MathML"> 头奶牛的品种编号。

接下来 lns="http://www.w3.org/1998/Math/MathML"> 行,每行两个整数 lns="http://www.w3.org/1998/Math/MathML">,,表示第 lns="http://www.w3.org/1998/Math/MathML"> 次查询的范围是 lns="http://www.w3.org/1998/Math/MathML">[,]

输出

对于每个查询,输出三个整数,分别是指定区间内品种 lns="http://www.w3.org/1998/Math/MathML">1 的奶牛数量,品种 lns="http://www.w3.org/1998/Math/MathML">2 的奶牛数量,品种 lns="http://www.w3.org/1998/Math/MathML">3 的奶牛数量。

样例输入

6 3
2
1
1
3
2
1
1 6
3 3
2 4

样例输出

3 2 1
1 0 0
2 0 1