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

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

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

l = A("l")
m = B("m")
f = C("f")
b = C("b")
d = A("d")
j = B("j")
n = B("n")
a = A("a")
h = C("h")

l.y = h
l.w = b
m.x = j
f.u = l
b.u = d
d.y = f
d.w = f
j.x = m
n.x = m
a.y = b
a.w = f
h.u = a
assert h.u.w.u.w.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

l = A("l")
m = B("m")
f = C("f")
b = C("b")
d = A("d")
j = B("j")
n = B("n")
a = A("a")
h = C("h")

l.y = h
l.w = b
m.x = j
f.u = l
b.u = d
d.y = f
d.w = f
j.x = m
n.x = m
a.y = b
a.w = f
h.u = a
assert h.u.w.u.w.u.y.txt == "f"