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

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

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

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

h = A("h")
a = B("a")
c = C("c")
i = D("i")
k = A("k")
m = B("m")

h.s = k
h.z = m
h.o = m
a.q = i
a.p = i
c.s = m
c.q = i
i.t = k
i.s = c
k.s = h
k.z = a
k.o = m
m.q = i
m.p = i
assert m.p.s.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: B = None
        self.o: B = None
        self.txt = txt

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

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

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

h = A("h")
a = B("a")
c = C("c")
i = D("i")
k = A("k")
m = B("m")

h.s = k
h.z = m
h.o = m
a.q = i
a.p = i
c.s = m
c.q = i
i.t = k
i.s = c
k.s = h
k.z = a
k.o = m
m.q = i
m.p = i
assert m.p.s.s.q.txt == "i"