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

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

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

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

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

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

m.q = f
m.r = g
m.t = e
f.v = h
f.x = h
f.u = e
e.p = f
e.z = g
g.r = f
h.x = e
h.v = e
h.r = f
h.u = m
assert f.v.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: D = None
        self.t: C = None
        self.txt = txt

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

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

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

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

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

m.q = f
m.r = g
m.t = e
f.v = h
f.x = h
f.u = e
e.p = f
e.z = g
g.r = f
h.x = e
h.v = e
h.r = f
h.u = m
assert f.v.u.r.txt == "g"