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

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

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

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

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

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

n.u = a
n.v = e
d.t = a
d.o = k
a.u = n
a.v = d
k.t = a
k.o = d
e.t = j
e.o = d
j.u = n
j.v = e
c.t = n
c.o = k
assert k.o.o.t.v.o.txt == "k"