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

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

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

f = A("f")
l = B("l")
h = C("h")
j = A("j")
k = C("k")
a = B("a")

f.z = a
f.s = l
f.q = l
l.x = h
h.w = a
h.y = k
j.z = l
j.q = l
j.s = a
k.w = l
k.y = h
a.x = h
assert k.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: B = None
        self.q: B = None
        self.txt = txt

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

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

f = A("f")
l = B("l")
h = C("h")
j = A("j")
k = C("k")
a = B("a")

f.z = a
f.s = l
f.q = l
l.x = h
h.w = a
h.y = k
j.z = l
j.q = l
j.s = a
k.w = l
k.y = h
a.x = h
assert k.y.y.y.txt == "h"