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

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

a.q = g
a.p = k
a.z = d
c.r = k
d.u = f
d.y = f
d.p = n
f.p = d
f.t = k
g.z = c
k.z = c
b.u = f
b.y = f
b.p = d
i.q = g
i.p = g
i.z = b
n.u = f
n.y = f
n.p = b
assert d.p.y.p.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.p: E = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

a.q = g
a.p = k
a.z = d
c.r = k
d.u = f
d.y = f
d.p = n
f.p = d
f.t = k
g.z = c
k.z = c
b.u = f
b.y = f
b.p = d
i.q = g
i.p = g
i.z = b
n.u = f
n.y = f
n.p = b
assert d.p.y.p.p.y.txt == "f"