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

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

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

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

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

i.s = e
i.q = m
e.z = i
e.o = i
e.v = m
m.z = e
h.y = e
h.w = m
assert m.z.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.q: C = None
        self.txt = txt

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

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

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

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

i.s = e
i.q = m
e.z = i
e.o = i
e.v = m
m.z = e
h.y = e
h.w = m
assert m.z.o.q.txt == "m"