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

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

n = A("n")
i = B("i")
a = A("a")
f = B("f")
d = B("d")
j = B("j")
m = A("m")
c = B("c")

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

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

n = A("n")
i = B("i")
a = A("a")
f = B("f")
d = B("d")
j = B("j")
m = A("m")
c = B("c")

n.v = a
n.o = j
i.u = n
a.v = m
a.o = i
f.u = m
d.u = a
j.u = n
m.v = a
m.o = f
c.u = a
assert a.o.u.o.u.txt == "n"