class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.x: B = None
        self.r: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: E = None
        self.q: B = None
        self.r: A = None
        self.t: B = None
        self.y: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: F = None
        self.z: D = None
        self.s: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

a = A("a")
j = B("j")
n = C("n")
h = D("h")
i = E("i")
l = F("l")

a.q = i
a.x = j
a.r = j
j.s = i
j.x = h
n.q = i
h.w = i
h.q = j
h.t = j
h.r = a
h.y = n
i.y = l
i.z = h
i.s = h
l.t = a
assert j.x.w.z.w.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.x: B = None
        self.r: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: E = None
        self.q: B = None
        self.r: A = None
        self.t: B = None
        self.y: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: F = None
        self.z: D = None
        self.s: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

a = A("a")
j = B("j")
n = C("n")
h = D("h")
i = E("i")
l = F("l")

a.q = i
a.x = j
a.r = j
j.s = i
j.x = h
n.q = i
h.w = i
h.q = j
h.t = j
h.r = a
h.y = n
i.y = l
i.z = h
i.s = h
l.t = a
assert j.x.w.z.w.z.y.txt == "n"