class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.s: C = None
        self.z: C = None
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.z: B = None
        self.x: C = None
        self.w: A = None
        self.txt = txt

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

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

g = A("g")
d = B("d")
m = C("m")
f = D("f")
c = B("c")
h = B("h")
a = A("a")
e = B("e")

g.w = d
g.s = m
g.z = m
g.u = f
d.s = f
d.z = e
d.x = m
d.w = a
m.t = h
f.q = a
f.x = g
f.o = m
c.s = f
c.z = h
c.x = m
c.w = g
h.s = f
h.z = e
h.x = m
h.w = g
a.w = h
a.s = m
a.z = m
a.u = f
e.s = f
e.z = h
e.x = m
e.w = g
assert f.o.t.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.s: C = None
        self.z: C = None
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.z: B = None
        self.x: C = None
        self.w: A = None
        self.txt = txt

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

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

g = A("g")
d = B("d")
m = C("m")
f = D("f")
c = B("c")
h = B("h")
a = A("a")
e = B("e")

g.w = d
g.s = m
g.z = m
g.u = f
d.s = f
d.z = e
d.x = m
d.w = a
m.t = h
f.q = a
f.x = g
f.o = m
c.s = f
c.z = h
c.x = m
c.w = g
h.s = f
h.z = e
h.x = m
h.w = g
a.w = h
a.s = m
a.z = m
a.u = f
e.s = f
e.z = h
e.x = m
e.w = g
assert f.o.t.s.o.txt == "m"