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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: C = None
        self.txt = txt

n = A("n")
k = B("k")
m = C("m")
g = D("g")
i = E("i")
l = D("l")
d = B("d")

n.p = m
n.u = l
k.z = d
k.v = d
k.p = d
k.t = n
m.t = k
m.s = i
g.p = k
g.q = d
i.u = n
i.o = m
l.p = k
l.q = d
d.z = k
d.v = k
d.p = k
d.t = n
assert g.q.t.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: C = None
        self.txt = txt

n = A("n")
k = B("k")
m = C("m")
g = D("g")
i = E("i")
l = D("l")
d = B("d")

n.p = m
n.u = l
k.z = d
k.v = d
k.p = d
k.t = n
m.t = k
m.s = i
g.p = k
g.q = d
i.u = n
i.o = m
l.p = k
l.q = d
d.z = k
d.v = k
d.p = k
d.t = n
assert g.q.t.u.p.txt == "k"