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.w: B = None
        self.o: B = None
        self.txt = txt

g = A("g")
h = B("h")
a = A("a")
l = B("l")
d = A("d")
c = A("c")
e = A("e")
j = A("j")
f = B("f")
b = A("b")

g.x = e
g.y = c
h.w = f
h.o = f
a.x = g
a.y = g
l.w = f
l.o = h
d.x = b
d.y = c
c.x = a
c.y = e
e.x = a
e.y = a
j.x = a
j.y = b
f.w = l
f.o = l
b.x = e
b.y = c
assert f.w.w.o.o.w.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.w: B = None
        self.o: B = None
        self.txt = txt

g = A("g")
h = B("h")
a = A("a")
l = B("l")
d = A("d")
c = A("c")
e = A("e")
j = A("j")
f = B("f")
b = A("b")

g.x = e
g.y = c
h.w = f
h.o = f
a.x = g
a.y = g
l.w = f
l.o = h
d.x = b
d.y = c
c.x = a
c.y = e
e.x = a
e.y = a
j.x = a
j.y = b
f.w = l
f.o = l
b.x = e
b.y = c
assert f.w.w.o.o.w.txt == "f"