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

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

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

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

h.y = j
j.o = h
l.z = h
l.t = j
l.v = j
assert l.z.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

h.y = j
j.o = h
l.z = h
l.t = j
l.v = j
assert l.z.y.o.txt == "h"