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

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

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

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

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

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

i.w = m
j.v = c
a.w = n
l.v = c
m.v = i
d.w = n
c.w = n
n.v = i
assert j.v.w.v.w.v.txt == "i"