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

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

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

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

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

d = A("d")
i = B("i")
f = C("f")
g = D("g")
n = E("n")
h = C("h")

d.o = g
d.u = g
d.y = g
d.s = g
d.x = h
i.p = g
f.s = d
f.z = d
f.r = i
f.t = h
g.o = d
n.u = g
n.q = g
n.t = d
n.v = i
h.s = d
h.z = d
h.r = i
h.t = f
assert d.s.o.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.u: D = None
        self.x: C = None
        self.y: D = None
        self.s: D = None
        self.txt = txt

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

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

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

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

d = A("d")
i = B("i")
f = C("f")
g = D("g")
n = E("n")
h = C("h")

d.o = g
d.u = g
d.y = g
d.s = g
d.x = h
i.p = g
f.s = d
f.z = d
f.r = i
f.t = h
g.o = d
n.u = g
n.q = g
n.t = d
n.v = i
h.s = d
h.z = d
h.r = i
h.t = f
assert d.s.o.x.r.txt == "i"