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

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

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

n = A("n")
a = B("a")
c = C("c")
h = C("h")

n.q = a
a.r = n
c.o = h
c.t = h
c.z = a
h.o = c
h.t = c
h.z = a
assert c.o.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

n = A("n")
a = B("a")
c = C("c")
h = C("h")

n.q = a
a.r = n
c.o = h
c.t = h
c.z = a
h.o = c
h.t = c
h.z = a
assert c.o.t.t.txt == "h"