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

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

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

i = A("i")
e = B("e")
l = C("l")
f = C("f")
d = A("d")
n = B("n")
m = C("m")
b = C("b")

i.y = d
e.u = d
e.s = m
l.p = m
l.w = n
f.p = b
f.w = n
d.y = i
n.u = d
n.s = l
m.p = l
m.w = n
b.p = m
b.w = e
assert l.w.u.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

i = A("i")
e = B("e")
l = C("l")
f = C("f")
d = A("d")
n = B("n")
m = C("m")
b = C("b")

i.y = d
e.u = d
e.s = m
l.p = m
l.w = n
f.p = b
f.w = n
d.y = i
n.u = d
n.s = l
m.p = l
m.w = n
b.p = m
b.w = e
assert l.w.u.y.y.txt == "d"