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

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

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

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

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

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

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

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

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