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

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

n = A("n")
m = B("m")
h = C("h")
c = D("c")
k = E("k")
j = D("j")

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

n = A("n")
m = B("m")
h = C("h")
c = D("c")
k = E("k")
j = D("j")

n.t = c
n.r = k
m.s = k
m.y = j
m.t = n
h.r = m
c.z = m
k.q = h
j.z = m
assert c.z.s.q.txt == "h"