class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.t: C = None
        self.s: B = None
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: A = None
        self.p: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: A = None
        self.s: B = None
        self.txt = txt

f = A("f")
c = B("c")
d = C("d")
l = D("l")
e = B("e")
k = C("k")
b = A("b")
g = A("g")
a = C("a")
i = D("i")

f.r = i
f.p = i
f.t = d
f.s = e
c.p = a
d.v = g
d.z = b
d.p = l
l.t = g
l.o = g
l.s = e
e.p = d
k.v = g
k.z = g
k.p = l
b.r = l
b.p = l
b.t = k
b.s = e
g.r = l
g.p = l
g.t = a
g.s = c
a.v = b
a.z = g
a.p = i
i.t = f
i.o = b
i.s = e
assert c.p.p.s.p.p.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.t: C = None
        self.s: B = None
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: A = None
        self.p: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: A = None
        self.s: B = None
        self.txt = txt

f = A("f")
c = B("c")
d = C("d")
l = D("l")
e = B("e")
k = C("k")
b = A("b")
g = A("g")
a = C("a")
i = D("i")

f.r = i
f.p = i
f.t = d
f.s = e
c.p = a
d.v = g
d.z = b
d.p = l
l.t = g
l.o = g
l.s = e
e.p = d
k.v = g
k.z = g
k.p = l
b.r = l
b.p = l
b.t = k
b.s = e
g.r = l
g.p = l
g.t = a
g.s = c
a.v = b
a.z = g
a.p = i
i.t = f
i.o = b
i.s = e
assert c.p.p.s.p.p.s.p.txt == "d"