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

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

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

n = A("n")
k = B("k")
b = C("b")
e = C("e")
f = A("f")
d = B("d")
l = A("l")
j = C("j")
c = A("c")
h = C("h")

n.u = e
k.y = c
b.p = k
e.p = d
f.u = e
d.y = n
l.u = b
j.p = d
c.u = e
h.p = k
assert n.u.p.y.u.p.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

n = A("n")
k = B("k")
b = C("b")
e = C("e")
f = A("f")
d = B("d")
l = A("l")
j = C("j")
c = A("c")
h = C("h")

n.u = e
k.y = c
b.p = k
e.p = d
f.u = e
d.y = n
l.u = b
j.p = d
c.u = e
h.p = k
assert n.u.p.y.u.p.y.u.txt == "e"