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

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

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

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

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

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

i.w = g
i.o = h
k.o = h
k.x = d
d.u = i
d.r = i
d.y = c
l.o = d
l.p = n
l.q = h
l.z = g
l.t = c
n.x = i
n.r = c
c.o = i
c.x = d
h.w = g
h.o = i
g.x = i
g.r = c
assert g.r.x.u.w.r.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.o: A = None
        self.txt = txt

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

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

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

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

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

i.w = g
i.o = h
k.o = h
k.x = d
d.u = i
d.r = i
d.y = c
l.o = d
l.p = n
l.q = h
l.z = g
l.t = c
n.x = i
n.r = c
c.o = i
c.x = d
h.w = g
h.o = i
g.x = i
g.r = c
assert g.r.x.u.w.r.x.y.txt == "c"