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

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

h = A("h")
f = B("f")
d = A("d")
l = A("l")
m = A("m")
n = A("n")

h.x = d
f.u = m
d.x = n
l.x = h
m.x = l
n.x = l
assert h.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

h = A("h")
f = B("f")
d = A("d")
l = A("l")
m = A("m")
n = A("n")

h.x = d
f.u = m
d.x = n
l.x = h
m.x = l
n.x = l
assert h.x.x.x.txt == "l"