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

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

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

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

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

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

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