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

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

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

i = A("i")
f = B("f")
a = C("a")
b = A("b")
l = C("l")
n = C("n")

i.q = b
i.u = f
f.z = n
a.s = f
a.w = f
b.q = i
b.u = f
l.s = f
l.w = f
n.s = f
n.w = f
assert a.w.z.s.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: B = None
        self.txt = txt

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

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

i = A("i")
f = B("f")
a = C("a")
b = A("b")
l = C("l")
n = C("n")

i.q = b
i.u = f
f.z = n
a.s = f
a.w = f
b.q = i
b.u = f
l.s = f
l.w = f
n.s = f
n.w = f
assert a.w.z.s.z.s.txt == "f"