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

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

l = A("l")
h = B("h")
m = A("m")
b = A("b")
k = B("k")
e = B("e")
n = B("n")
j = A("j")

l.v = m
h.w = e
m.v = b
b.v = m
k.w = e
e.w = k
n.w = h
j.v = b
assert h.w.w.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

l = A("l")
h = B("h")
m = A("m")
b = A("b")
k = B("k")
e = B("e")
n = B("n")
j = A("j")

l.v = m
h.w = e
m.v = b
b.v = m
k.w = e
e.w = k
n.w = h
j.v = b
assert h.w.w.w.w.w.w.w.w.txt == "k"