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

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

j = A("j")
d = B("d")
b = A("b")
h = B("h")
f = B("f")
i = A("i")
a = B("a")
k = A("k")
g = B("g")

j.w = h
j.v = a
d.x = i
b.w = h
b.v = g
h.x = i
f.x = i
i.w = d
i.v = f
a.x = b
k.w = h
k.v = a
g.x = k
assert b.w.x.v.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.v: B = None
        self.txt = txt

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

j = A("j")
d = B("d")
b = A("b")
h = B("h")
f = B("f")
i = A("i")
a = B("a")
k = A("k")
g = B("g")

j.w = h
j.v = a
d.x = i
b.w = h
b.v = g
h.x = i
f.x = i
i.w = d
i.v = f
a.x = b
k.w = h
k.v = a
g.x = k
assert b.w.x.v.x.w.x.txt == "i"