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")
k = B("k")
c = B("c")
j = A("j")
i = A("i")
a = A("a")
m = B("m")
f = B("f")
l = B("l")
n = B("n")

b.v = i
k.u = a
c.u = a
j.v = b
i.v = a
a.v = i
m.u = i
f.u = j
l.u = b
n.u = j
assert n.u.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")
k = B("k")
c = B("c")
j = A("j")
i = A("i")
a = A("a")
m = B("m")
f = B("f")
l = B("l")
n = B("n")

b.v = i
k.u = a
c.u = a
j.v = b
i.v = a
a.v = i
m.u = i
f.u = j
l.u = b
n.u = j
assert n.u.v.v.v.v.v.v.v.v.txt == "i"