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

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

n = A("n")
d = B("d")
j = B("j")
h = A("h")
a = B("a")
i = B("i")
e = A("e")
k = B("k")

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

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

n = A("n")
d = B("d")
j = B("j")
h = A("h")
a = B("a")
i = B("i")
e = A("e")
k = B("k")

n.v = h
n.u = d
d.o = h
d.u = e
j.o = h
j.u = e
h.v = e
h.u = i
a.o = h
a.u = h
i.o = n
i.u = h
e.v = h
e.u = j
k.o = h
k.u = n
assert a.o.v.v.u.o.v.u.txt == "i"