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

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

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

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

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

g = A("g")
d = B("d")
c = C("c")
m = D("m")
a = E("a")
b = D("b")

g.u = b
g.q = b
d.x = c
d.s = a
c.y = d
c.x = g
m.s = g
m.z = d
m.v = b
m.o = b
m.y = a
a.q = g
a.s = g
a.p = d
a.z = b
b.s = g
b.z = d
b.v = m
b.o = m
b.y = a
assert g.q.v.o.z.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.q: D = None
        self.txt = txt

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

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

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

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

g = A("g")
d = B("d")
c = C("c")
m = D("m")
a = E("a")
b = D("b")

g.u = b
g.q = b
d.x = c
d.s = a
c.y = d
c.x = g
m.s = g
m.z = d
m.v = b
m.o = b
m.y = a
a.q = g
a.s = g
a.p = d
a.z = b
b.s = g
b.z = d
b.v = m
b.o = m
b.y = a
assert g.q.v.o.z.s.p.txt == "d"