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

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

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

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

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

a = A("a")
b = B("b")
g = C("g")
k = D("k")
j = E("j")
i = E("i")
n = A("n")
f = C("f")
m = D("m")
h = A("h")

a.x = k
a.y = g
a.o = g
a.z = f
b.r = j
g.z = b
k.o = b
k.u = b
k.w = b
k.x = g
j.q = n
j.y = b
j.v = b
j.x = f
i.q = n
i.y = b
i.v = b
i.x = f
n.x = k
n.y = g
n.z = g
n.o = f
f.z = b
m.o = b
m.u = b
m.w = b
m.x = f
h.x = m
h.y = f
h.z = f
h.o = g
assert i.q.x.x.z.r.y.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: C = None
        self.z: C = None
        self.o: C = None
        self.txt = txt

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

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

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

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

a = A("a")
b = B("b")
g = C("g")
k = D("k")
j = E("j")
i = E("i")
n = A("n")
f = C("f")
m = D("m")
h = A("h")

a.x = k
a.y = g
a.o = g
a.z = f
b.r = j
g.z = b
k.o = b
k.u = b
k.w = b
k.x = g
j.q = n
j.y = b
j.v = b
j.x = f
i.q = n
i.y = b
i.v = b
i.x = f
n.x = k
n.y = g
n.z = g
n.o = f
f.z = b
m.o = b
m.u = b
m.w = b
m.x = f
h.x = m
h.y = f
h.z = f
h.o = g
assert i.q.x.x.z.r.y.r.q.txt == "n"