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

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

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

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: F = None
        self.u: E = None
        self.txt = txt

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

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

h = A("h")
a = B("a")
l = C("l")
n = D("n")
e = E("e")
k = F("k")

h.r = n
h.s = l
h.z = k
a.q = e
l.x = n
l.p = h
n.p = h
n.q = k
n.u = e
e.q = h
e.o = n
k.z = e
assert h.r.p.r.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.s: C = None
        self.z: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: F = None
        self.u: E = None
        self.txt = txt

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

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

h = A("h")
a = B("a")
l = C("l")
n = D("n")
e = E("e")
k = F("k")

h.r = n
h.s = l
h.z = k
a.q = e
l.x = n
l.p = h
n.p = h
n.q = k
n.u = e
e.q = h
e.o = n
k.z = e
assert h.r.p.r.q.z.txt == "e"