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

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

n = A("n")
k = B("k")
m = A("m")
c = B("c")
b = B("b")
g = A("g")
j = A("j")
e = B("e")

n.u = k
k.v = b
m.u = e
c.v = e
b.v = e
g.u = c
j.u = c
e.v = b
assert m.u.v.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

n = A("n")
k = B("k")
m = A("m")
c = B("c")
b = B("b")
g = A("g")
j = A("j")
e = B("e")

n.u = k
k.v = b
m.u = e
c.v = e
b.v = e
g.u = c
j.u = c
e.v = b
assert m.u.v.v.v.v.v.v.v.txt == "b"