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

b = A("b")
n = B("n")
l = B("l")
i = A("i")
j = B("j")
h = A("h")
d = B("d")
c = A("c")
k = A("k")

b.v = i
n.w = d
l.w = j
i.v = b
j.w = n
h.v = k
d.w = j
c.v = h
k.v = h
assert b.v.v.v.v.v.v.v.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

b = A("b")
n = B("n")
l = B("l")
i = A("i")
j = B("j")
h = A("h")
d = B("d")
c = A("c")
k = A("k")

b.v = i
n.w = d
l.w = j
i.v = b
j.w = n
h.v = k
d.w = j
c.v = h
k.v = h
assert b.v.v.v.v.v.v.v.txt == "i"