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

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

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

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

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

d = A("d")
i = B("i")
h = C("h")
b = D("b")
f = E("f")
n = E("n")

d.t = b
d.s = b
d.z = h
i.s = f
i.v = d
h.x = b
h.s = i
h.q = i
h.v = f
b.q = n
b.r = d
f.v = h
f.u = h
f.p = n
n.v = h
n.u = h
n.p = f
assert d.z.v.v.s.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.s: D = None
        self.z: C = None
        self.txt = txt

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

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

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

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

d = A("d")
i = B("i")
h = C("h")
b = D("b")
f = E("f")
n = E("n")

d.t = b
d.s = b
d.z = h
i.s = f
i.v = d
h.x = b
h.s = i
h.q = i
h.v = f
b.q = n
b.r = d
f.v = h
f.u = h
f.p = n
n.v = h
n.u = h
n.p = f
assert d.z.v.v.s.v.t.txt == "b"