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

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

l = A("l")
b = B("b")
i = B("i")
h = A("h")
a = B("a")
k = B("k")

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

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

l = A("l")
b = B("b")
i = B("i")
h = A("h")
a = B("a")
k = B("k")

l.x = h
b.y = k
i.y = b
h.x = l
a.y = k
k.y = b
assert k.y.y.y.txt == "b"