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

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

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

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

f.r = j
f.t = j
f.z = h
i.z = j
i.w = k
i.q = k
a.z = k
a.u = j
j.r = f
j.t = f
j.z = i
h.z = f
h.w = k
h.q = k
k.z = j
k.w = h
k.q = h
assert f.r.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: B = None
        self.t: A = None
        self.txt = txt

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

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

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

f.r = j
f.t = j
f.z = h
i.z = j
i.w = k
i.q = k
a.z = k
a.u = j
j.r = f
j.t = f
j.z = i
h.z = f
h.w = k
h.q = k
k.z = j
k.w = h
k.q = h
assert f.r.z.w.txt == "k"