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

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

f = A("f")
m = B("m")
g = C("g")
j = B("j")
i = B("i")
a = C("a")
n = A("n")
b = C("b")

f.p = b
f.u = b
f.z = g
m.s = j
g.q = n
j.s = i
i.s = m
a.q = n
n.p = b
n.u = b
n.z = g
b.q = n
assert i.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: C = None
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

f = A("f")
m = B("m")
g = C("g")
j = B("j")
i = B("i")
a = C("a")
n = A("n")
b = C("b")

f.p = b
f.u = b
f.z = g
m.s = j
g.q = n
j.s = i
i.s = m
a.q = n
n.p = b
n.u = b
n.z = g
b.q = n
assert i.s.s.s.s.s.txt == "j"