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

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

n = A("n")
l = B("l")
c = A("c")
j = B("j")
e = B("e")
i = B("i")
b = A("b")
f = A("f")

n.y = f
n.v = e
l.w = c
l.o = f
c.y = f
c.v = j
j.w = b
j.o = n
e.w = c
e.o = n
i.w = c
i.o = c
b.y = c
b.v = e
f.y = c
f.v = j
assert j.o.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: B = None
        self.txt = txt

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

n = A("n")
l = B("l")
c = A("c")
j = B("j")
e = B("e")
i = B("i")
b = A("b")
f = A("f")

n.y = f
n.v = e
l.w = c
l.o = f
c.y = f
c.v = j
j.w = b
j.o = n
e.w = c
e.o = n
i.w = c
i.o = c
b.y = c
b.v = e
f.y = c
f.v = j
assert j.o.v.o.txt == "n"