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

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: C = None
        self.txt = txt

f = A("f")
h = B("h")
d = C("d")
l = D("l")
a = E("a")
m = C("m")

f.v = m
f.r = h
h.x = l
d.z = m
d.x = f
d.r = f
d.t = a
l.s = f
a.w = f
a.x = m
m.z = d
m.x = f
m.r = f
m.t = a
assert m.z.z.x.r.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: C = None
        self.txt = txt

f = A("f")
h = B("h")
d = C("d")
l = D("l")
a = E("a")
m = C("m")

f.v = m
f.r = h
h.x = l
d.z = m
d.x = f
d.r = f
d.t = a
l.s = f
a.w = f
a.x = m
m.z = d
m.x = f
m.r = f
m.t = a
assert m.z.z.x.r.x.s.txt == "f"