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

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

f = A("f")
m = B("m")
c = C("c")
n = A("n")
j = C("j")
k = B("k")
g = A("g")

f.x = n
f.o = c
f.q = m
m.p = c
m.u = j
m.o = f
c.p = j
n.x = f
n.o = j
n.q = k
j.p = c
k.p = j
k.u = c
k.o = g
g.x = n
g.o = j
g.q = k
assert m.u.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: C = None
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

f = A("f")
m = B("m")
c = C("c")
n = A("n")
j = C("j")
k = B("k")
g = A("g")

f.x = n
f.o = c
f.q = m
m.p = c
m.u = j
m.o = f
c.p = j
n.x = f
n.o = j
n.q = k
j.p = c
k.p = j
k.u = c
k.o = g
g.x = n
g.o = j
g.q = k
assert m.u.p.p.txt == "j"