#!/usr/bin/perl

use v5.30;
use strict;

my $row = join('', 'a' .. 'p');
# my $row = join('', 'a' .. 'e');

for my $move (split /,/, <>) {
	chomp $move;
	if ($move =~ /s(\d+)/) {
		$row =~ s/(.*)(.{$1})/\2\1/;
	} elsif ($move =~ /x(\d+)\/(\d+)/) {
		my ($a, $b) = (substr($row, $1, 1), substr($row, $2, 1));
		substr($row, $1, 1) = $b;
		substr($row, $2, 1) = $a;
	} elsif ($move =~ /p(\w)\/(\w)/) {
		eval "\$row =~ y/$1$2/$2$1/";
	}
	say $row;
}

say $row;

