PascalABC.NET
begin
var a := ReadArrInteger(6);
for var i := 0 to 2 do
var n := a[2 * i];
var m := a[2 * i + 1];
if m <= n then
Println(0)
else
var p := 1;
for var j := 2 to n do
p := p * j mod m;
Println(p)
end
end.
PascalABC.NET
begin
var a := ReadArrInteger(6);
for var i := 0 to 2 do
begin
var n := a[2 * i];
var m := a[2 * i + 1];
if m <= n then
Println(0)
else
begin
var p := 1;
for var j := 2 to n do
p := p * j mod m;
Println(p)
end
end
end.