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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.o: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.x: C = None
        self.w: E = None
        self.y: D = None
        self.txt = txt

a = A("a")
i = B("i")
j = C("j")
k = D("k")
g = E("g")
h = A("h")
n = E("n")
d = C("d")

a.p = n
i.x = k
i.o = g
j.p = k
j.z = d
j.s = i
k.q = i
k.v = d
g.x = d
g.w = n
g.y = k
h.p = g
n.x = j
n.w = g
n.y = k
d.p = k
d.z = j
d.s = i
assert g.y.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.o: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.x: C = None
        self.w: E = None
        self.y: D = None
        self.txt = txt

a = A("a")
i = B("i")
j = C("j")
k = D("k")
g = E("g")
h = A("h")
n = E("n")
d = C("d")

a.p = n
i.x = k
i.o = g
j.p = k
j.z = d
j.s = i
k.q = i
k.v = d
g.x = d
g.w = n
g.y = k
h.p = g
n.x = j
n.w = g
n.y = k
d.p = k
d.z = j
d.s = i
assert g.y.v.z.txt == "j"