{% set ns = namespace(left=0, right=0) %}
{% for i in range(20) %}
{% if uniquePathsAt(elements, 'left-' ~ i ~ '$') | length != 0 %}
{% set ns.left = i %}
{% endif %}
{% if uniquePathsAt(elements, 'right-' ~ i ~ '$') | length != 0 %}
{% set ns.right = i %}
{% endif %}
{% endfor %}
{% macro row_left(name, index, count) -%}
{% if count > 1 %}
{%endif %}
{% if index == count %}
{%endif %}
{%- endmacro %}
{% macro col_left(count, offsetX, offsetY) -%}
{% set name = 'left' %}
{% for index in range(count) %}
{{ row_left(name, index+1, count) }}
{% endfor %}
{%- endmacro %}
{% macro row_right(name, index, count) -%}
{% if count > 1 %}
{%endif %}
{% if index == count %}
{%endif %}
{%- endmacro %}
{% macro col_right(count, offsetX, offsetY) -%}
{% set name = 'right' %}
{% for index in range(count) %}
{{ row_right(name, index+1, count) }}
{% endfor %}
{%- endmacro %}