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

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

c = A("c")
b = B("b")
h = A("h")
l = A("l")

c.y = l
b.v = h
b.x = c
h.y = c
l.y = c
assert b.x.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

c = A("c")
b = B("b")
h = A("h")
l = A("l")

c.y = l
b.v = h
b.x = c
h.y = c
l.y = c
assert b.x.y.y.y.txt == "l"