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

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

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

b.v = j
n.u = b
d.v = b
j.v = b
a.u = f
l.u = m
m.v = f
f.v = j
h.v = j
assert m.v.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.u: A = None
        self.txt = txt

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

b.v = j
n.u = b
d.v = b
j.v = b
a.u = f
l.u = m
m.v = f
f.v = j
h.v = j
assert m.v.v.v.v.v.v.v.v.txt == "j"