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

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

h = A("h")
m = B("m")
k = A("k")
l = B("l")

h.y = k
m.s = l
m.v = l
k.y = h
l.s = m
l.v = m
assert h.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.s: B = None
        self.v: B = None
        self.txt = txt

h = A("h")
m = B("m")
k = A("k")
l = B("l")

h.y = k
m.s = l
m.v = l
k.y = h
l.s = m
l.v = m
assert h.y.y.y.txt == "k"