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

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: E = None
        self.r: A = None
        self.s: B = None
        self.v: B = None
        self.txt = txt

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

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

d.p = a
d.y = g
d.q = g
g.x = i
g.p = a
a.u = i
a.v = i
a.w = l
a.r = m
m.y = l
m.v = l
m.u = h
m.r = d
m.s = g
h.q = a
h.z = i
l.x = i
l.p = a
i.p = a
i.y = g
i.q = l
assert g.p.r.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: B = None
        self.q: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: E = None
        self.r: A = None
        self.s: B = None
        self.v: B = None
        self.txt = txt

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

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

d.p = a
d.y = g
d.q = g
g.x = i
g.p = a
a.u = i
a.v = i
a.w = l
a.r = m
m.y = l
m.v = l
m.u = h
m.r = d
m.s = g
h.q = a
h.z = i
l.x = i
l.p = a
i.p = a
i.y = g
i.q = l
assert g.p.r.s.p.txt == "a"