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

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

c = A("c")
j = B("j")
k = A("k")
b = A("b")
a = B("a")
i = B("i")
h = B("h")
f = B("f")
n = B("n")

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

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

c = A("c")
j = B("j")
k = A("k")
b = A("b")
a = B("a")
i = B("i")
h = B("h")
f = B("f")
n = B("n")

c.o = h
c.v = i
j.u = a
k.o = j
k.v = h
b.o = a
b.v = j
a.u = n
i.u = a
h.u = f
f.u = n
n.u = h
assert j.u.u.u.txt == "h"