Please take a look at the function loopIndex() (which is not that easy, as I just realized, it has no manual page on its own). It will tell you the position within a loop OR a page order. So, you code might look like this:
$i = loopIndex();
if ($i < 2) {
$title = 'A';
} elseif ($i < 4) {
$title = 'B';
} else {
$title = 'C';
}
html('<h1>'.$title.'</h1>');