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

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

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

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

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

i = A("i")
e = B("e")
c = C("c")
a = D("a")
j = E("j")
b = E("b")

i.w = a
i.o = b
e.p = c
e.x = c
c.r = i
c.z = i
a.z = b
a.s = e
a.q = e
j.s = e
j.t = c
j.x = c
j.p = a
b.s = e
b.t = c
b.x = c
b.p = a
assert b.s.x.z.w.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.o: E = None
        self.txt = txt

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

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

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

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

i = A("i")
e = B("e")
c = C("c")
a = D("a")
j = E("j")
b = E("b")

i.w = a
i.o = b
e.p = c
e.x = c
c.r = i
c.z = i
a.z = b
a.s = e
a.q = e
j.s = e
j.t = c
j.x = c
j.p = a
b.s = e
b.t = c
b.x = c
b.p = a
assert b.s.x.z.w.z.s.txt == "e"