class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: B = None
        self.o: 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.t: B = None
        self.q: C = None
        self.r: A = None
        self.s: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: C = None
        self.txt = txt

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

k.w = e
k.o = e
k.p = f
f.y = k
e.t = f
e.q = a
e.r = i
e.s = k
c.z = f
c.r = e
a.t = f
a.q = e
a.r = i
a.s = i
d.z = f
d.r = a
i.w = a
i.o = a
i.p = f
assert k.p.y.p.y.p.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: B = None
        self.o: 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.t: B = None
        self.q: C = None
        self.r: A = None
        self.s: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: C = None
        self.txt = txt

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

k.w = e
k.o = e
k.p = f
f.y = k
e.t = f
e.q = a
e.r = i
e.s = k
c.z = f
c.r = e
a.t = f
a.q = e
a.r = i
a.s = i
d.z = f
d.r = a
i.w = a
i.o = a
i.p = f
assert k.p.y.p.y.p.y.p.txt == "f"