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

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

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

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

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

d = A("d")
h = B("h")
a = C("a")
f = D("f")
c = E("c")
b = E("b")
g = B("g")

d.r = b
d.z = c
d.u = c
d.x = h
h.p = f
h.x = d
h.q = d
h.z = a
h.t = a
a.o = b
a.z = b
f.s = a
f.q = a
f.v = b
f.z = g
f.r = g
c.t = d
b.t = d
g.p = f
g.x = d
g.q = d
g.z = a
g.t = a
assert g.t.z.t.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.z: E = None
        self.u: E = None
        self.x: B = None
        self.txt = txt

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

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

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

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

d = A("d")
h = B("h")
a = C("a")
f = D("f")
c = E("c")
b = E("b")
g = B("g")

d.r = b
d.z = c
d.u = c
d.x = h
h.p = f
h.x = d
h.q = d
h.z = a
h.t = a
a.o = b
a.z = b
f.s = a
f.q = a
f.v = b
f.z = g
f.r = g
c.t = d
b.t = d
g.p = f
g.x = d
g.q = d
g.z = a
g.t = a
assert g.t.z.t.u.t.txt == "d"