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

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

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

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

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

c = A("c")
m = B("m")
f = C("f")
k = D("k")
g = E("g")
e = B("e")
i = A("i")
h = E("h")

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

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

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

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

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

c = A("c")
m = B("m")
f = C("f")
k = D("k")
g = E("g")
e = B("e")
i = A("i")
h = E("h")

c.x = i
m.w = g
m.y = g
m.t = i
m.z = f
m.x = f
f.p = i
f.u = i
k.z = c
k.o = c
k.u = g
k.y = e
g.q = f
g.r = h
e.w = g
e.y = g
e.t = c
e.z = f
e.x = f
i.x = c
h.q = f
h.r = g
assert g.q.p.x.x.txt == "i"