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

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

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

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

h.x = l
f.t = n
n.z = f
n.y = f
n.q = h
l.t = n
assert h.x.t.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

h.x = l
f.t = n
n.z = f
n.y = f
n.q = h
l.t = n
assert h.x.t.q.x.txt == "l"