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

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

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

i = A("i")
f = B("f")
j = C("j")
e = B("e")
g = C("g")
k = B("k")

i.w = j
i.p = j
f.q = k
j.s = g
j.u = g
e.q = k
g.s = j
g.u = j
k.q = f
assert k.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: C = None
        self.txt = txt

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

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

i = A("i")
f = B("f")
j = C("j")
e = B("e")
g = C("g")
k = B("k")

i.w = j
i.p = j
f.q = k
j.s = g
j.u = g
e.q = k
g.s = j
g.u = j
k.q = f
assert k.q.q.q.q.q.txt == "f"