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

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

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

e = A("e")
l = B("l")
i = C("i")
d = C("d")
k = A("k")
f = B("f")
g = A("g")
m = A("m")

e.y = i
e.r = i
l.u = f
l.z = f
l.s = e
i.p = d
d.p = i
k.y = i
k.r = d
f.u = l
f.z = l
f.s = k
g.y = d
g.r = d
m.y = d
m.r = d
assert i.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: C = None
        self.txt = txt

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

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

e = A("e")
l = B("l")
i = C("i")
d = C("d")
k = A("k")
f = B("f")
g = A("g")
m = A("m")

e.y = i
e.r = i
l.u = f
l.z = f
l.s = e
i.p = d
d.p = i
k.y = i
k.r = d
f.u = l
f.z = l
f.s = k
g.y = d
g.r = d
m.y = d
m.r = d
assert i.p.p.p.p.p.txt == "d"