Create a loop that gets pages with their template

The snippet from codex is a bit redundant in your case. You can achieve what you need, by using snippets like these:

index.php

$mainpage = get_page_by_title( 'ROOT' );
$the_query = new WP_Query( array(
    'post_parent' => $mainpage->ID,
    'post_type'   => 'page',
) );

$index = 0;
while ( $the_query->have_posts() ) :
    $the_query->the_post();
    echo '<section class="page' . get_the_ID() . '">';
    get_template_part( 'foo', $index++ % 3 + 1 );
    echo '</section>';
endwhile;

wp_reset_postdata();

foo1.php

<div id="template-foo-1">
    <?php the_content() ?>
</div>

foo2.php

<div id="template-foo-2">
    <?php the_content() ?>
</div>

foo3.php

<div id="template-foo-3">
    <?php the_content() ?>
</div>