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

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

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

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

j.q = h
j.t = l
l.w = j
l.t = j
l.z = h
h.q = j
f.w = j
f.t = j
f.z = h
assert j.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.t: B = None
        self.txt = txt

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

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

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

j.q = h
j.t = l
l.w = j
l.t = j
l.z = h
h.q = j
f.w = j
f.t = j
f.z = h
assert j.q.q.q.txt == "h"