class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: A = None
        self.txt = txt

m = A("m")
c = B("c")
n = A("n")
f = A("f")
e = A("e")

m.u = f
m.p = c
c.t = n
c.o = m
n.u = f
n.p = c
f.u = m
f.p = c
e.u = n
e.p = c
assert c.o.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.p: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: A = None
        self.txt = txt

m = A("m")
c = B("c")
n = A("n")
f = A("f")
e = A("e")

m.u = f
m.p = c
c.t = n
c.o = m
n.u = f
n.p = c
f.u = m
f.p = c
e.u = n
e.p = c
assert c.o.u.p.txt == "c"