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

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

i = A("i")
j = B("j")
h = A("h")
d = B("d")
g = A("g")
f = A("f")
e = A("e")

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

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

i = A("i")
j = B("j")
h = A("h")
d = B("d")
g = A("g")
f = A("f")
e = A("e")

i.w = d
j.v = d
j.x = d
h.w = d
d.v = j
d.x = j
g.w = j
f.w = j
e.w = d
assert h.w.x.x.v.x.v.x.txt == "d"