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

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

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

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

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

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

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

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

h.y = l
l.v = h
n.q = h
assert h.y.v.y.txt == "l"