#include #include using namespace std; int main() { freopen("bcount.in", "r", stdin); freopen("bcount.out", "w", stdout); int n, q; cin >> n >> q; int cow_array[n]; for (int i = 0; i < n; i++) { int j; cin >> j; cow_array[i] = j; } for (int i = 0; i < q; i++) { int j, k; cin >> j >> k; int a = 0; int b = 0; int c = 0; for (int i = 0; i < abs(j - k) + 1; i++) { if (cow_array[i + j - 1] == 1) { a++; } else if (cow_array[i + j - 1] == 2) { b++; } else if (cow_array[i + j - 1] == 3) { c++; } } cout << a << " " << b << " " << c << endl; } }