#!/usr/bin/perl
use 5.016;
use warnings;
sub prestr
{ $_[1] >= 0 ? substr($_[0], 0, $_[1]) : '' }
sub f {
return prestr
($_[0], $p) . '10' . poststr
($_[0], $p + 2); }
say f('111');
say f('1110');
say f('101100');
say f('1101');
say f('10101');
IyEvdXNyL2Jpbi9wZXJsCnVzZSA1LjAxNjsKdXNlIHdhcm5pbmdzOwoKc3ViIHByZXN0ciB7ICRfWzFdID49IDAgPyBzdWJzdHIoJF9bMF0sIDAsICRfWzFdKSA6ICcnIH0Kc3ViIHBvc3RzdHIgeyBqb2luICcnLCBzb3J0IHNwbGl0IC8vLCBzdWJzdHIoJF9bMF0sICRfWzFdKSB9CgpzdWIgZiB7CglteSAkcCA9IHJpbmRleCAkX1swXSwgJzAxJzsKCXJldHVybiBwcmVzdHIoJF9bMF0sICRwKSAuICcxMCcgLiBwb3N0c3RyKCRfWzBdLCAkcCArIDIpOwp9CgpzYXkgZignMTExJyk7CnNheSBmKCcxMTEwJyk7CnNheSBmKCcxMDExMDAnKTsKc2F5IGYoJzExMDEnKTsKc2F5IGYoJzEwMTAxJyk7Cg==