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

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.y: C = None
        self.txt = txt

i = A("i")
a = B("a")
h = C("h")
e = D("e")
m = D("m")
b = B("b")

i.x = b
i.r = b
i.y = h
i.s = e
a.q = m
a.y = h
h.z = i
h.v = b
e.v = h
e.y = h
m.v = h
m.y = h
b.q = e
b.y = h
assert m.v.z.s.v.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: C = None
        self.s: D = None
        self.r: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.y: C = None
        self.txt = txt

i = A("i")
a = B("a")
h = C("h")
e = D("e")
m = D("m")
b = B("b")

i.x = b
i.r = b
i.y = h
i.s = e
a.q = m
a.y = h
h.z = i
h.v = b
e.v = h
e.y = h
m.v = h
m.y = h
b.q = e
b.y = h
assert m.v.z.s.v.v.q.txt == "e"