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

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

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

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

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

f = A("f")
m = B("m")
h = C("h")
b = D("b")
c = E("c")
k = E("k")

f.s = h
m.r = b
m.s = b
m.x = h
m.w = f
m.z = c
h.v = m
h.w = f
h.y = b
h.q = b
h.x = b
b.u = m
b.s = h
b.v = f
b.o = f
c.t = k
c.x = m
k.t = c
k.x = m
assert b.u.w.s.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

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

f = A("f")
m = B("m")
h = C("h")
b = D("b")
c = E("c")
k = E("k")

f.s = h
m.r = b
m.s = b
m.x = h
m.w = f
m.z = c
h.v = m
h.w = f
h.y = b
h.q = b
h.x = b
b.u = m
b.s = h
b.v = f
b.o = f
c.t = k
c.x = m
k.t = c
k.x = m
assert b.u.w.s.w.s.txt == "h"