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

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

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

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

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

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

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

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

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

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

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

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

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