I need help with creating regex for validating parameter string.

Parameter string consists of 2 optional groups of explicit characters. First group can contain only one occurrence of P, O, Z characters (order doesn't matter). Second group has same restrictions but can contain only characters t, c, p, m. If both groups are presented, they need to be delimited by a single space character.

So valid strings are:

```
P t
PO t
OZP ct
P tcmp
P
PZ
t
tp

```

etc.