static BinaryIndexedTree ReadString(string a) { var bit = new BinaryIndexedTree(a.Length); for (var i = 0; i < a.Length; ++i) { bit.Set(i, (a[i] == 'A') ? 1 : 2); } return(bit); }