\set seed random(1, 1000000000000)
\set i0 pr_perm(0, 4, :seed)
\set i1 pr_perm(1, 4, :seed)
\set i2 pr_perm(2, 4, :seed)
\set i3 pr_perm(3, 4, :seed)
INSERT INTO perm_count(perm) VALUES (:i0 + :i1*10 + :i2*100 + :i3*1000)
  ON CONFLICT (perm) DO
  UPDATE SET cnt = perm_count.cnt+1;
