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

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

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

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

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

c.t = h
c.z = h
c.s = m
i.s = e
i.z = j
i.p = k
i.q = h
k.x = e
k.y = e
k.z = e
m.r = e
m.q = e
h.t = c
h.z = c
h.s = e
e.r = m
e.q = m
j.s = m
j.z = i
j.p = k
j.q = c
assert m.r.r.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.z: A = None
        self.s: D = None
        self.txt = txt

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

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

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

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

c.t = h
c.z = h
c.s = m
i.s = e
i.z = j
i.p = k
i.q = h
k.x = e
k.y = e
k.z = e
m.r = e
m.q = e
h.t = c
h.z = c
h.s = e
e.r = m
e.q = m
j.s = m
j.z = i
j.p = k
j.q = c
assert m.r.r.q.q.q.txt == "e"