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

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

i = A("i")
f = B("f")
g = C("g")
l = A("l")
h = A("h")
a = C("a")
c = B("c")
d = A("d")
k = C("k")

i.y = h
i.x = l
f.w = l
g.y = f
l.y = i
l.x = h
h.y = l
h.x = d
a.y = f
c.w = l
d.y = h
d.x = i
k.y = c
assert h.y.y.y.x.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

i = A("i")
f = B("f")
g = C("g")
l = A("l")
h = A("h")
a = C("a")
c = B("c")
d = A("d")
k = C("k")

i.y = h
i.x = l
f.w = l
g.y = f
l.y = i
l.x = h
h.y = l
h.x = d
a.y = f
c.w = l
d.y = h
d.x = i
k.y = c
assert h.y.y.y.x.x.y.txt == "h"