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

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

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

n.v = h
c.u = k
k.u = h
j.u = g
i.v = h
d.u = c
g.u = k
f.v = h
l.v = k
h.u = d
assert c.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

n.v = h
c.u = k
k.u = h
j.u = g
i.v = h
d.u = c
g.u = k
f.v = h
l.v = k
h.u = d
assert c.u.u.u.u.txt == "c"