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

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

j = A("j")
l = B("l")
m = B("m")
k = A("k")
c = B("c")
a = B("a")
n = A("n")

j.u = a
j.v = m
l.w = j
m.w = n
k.u = c
k.v = m
c.w = n
a.w = k
n.u = m
n.v = c
assert j.u.w.v.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: B = None
        self.txt = txt

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

j = A("j")
l = B("l")
m = B("m")
k = A("k")
c = B("c")
a = B("a")
n = A("n")

j.u = a
j.v = m
l.w = j
m.w = n
k.u = c
k.v = m
c.w = n
a.w = k
n.u = m
n.v = c
assert j.u.w.v.w.u.w.txt == "n"