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

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

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

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

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

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

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

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

h.y = n
n.q = a
a.o = n
c.y = n
assert a.o.q.o.q.txt == "a"