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

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

a = A("a")
h = B("h")
i = A("i")
j = B("j")
f = A("f")
d = A("d")
l = A("l")
m = A("m")
e = B("e")

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

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

a = A("a")
h = B("h")
i = A("i")
j = B("j")
f = A("f")
d = A("d")
l = A("l")
m = A("m")
e = B("e")

a.x = m
a.y = m
h.v = l
h.w = e
i.x = l
i.y = f
j.v = m
j.w = e
f.x = m
f.y = i
d.x = m
d.y = f
l.x = d
l.y = d
m.x = f
m.y = l
e.v = a
e.w = h
assert l.x.y.x.x.x.txt == "m"