class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.p: D = None
        self.r: B = None
        self.s: E = None
        self.txt = txt

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

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

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

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

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

l = A("l")
h = B("h")
d = C("d")
a = D("a")
m = E("m")
e = F("e")

l.o = m
l.s = m
l.p = a
l.r = h
h.o = m
d.q = e
d.z = l
d.r = m
a.o = h
a.z = h
a.s = d
m.t = d
m.r = a
e.s = a
assert a.s.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.p: D = None
        self.r: B = None
        self.s: E = None
        self.txt = txt

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

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

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

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

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

l = A("l")
h = B("h")
d = C("d")
a = D("a")
m = E("m")
e = F("e")

l.o = m
l.s = m
l.p = a
l.r = h
h.o = m
d.q = e
d.z = l
d.r = m
a.o = h
a.z = h
a.s = d
m.t = d
m.r = a
e.s = a
assert a.s.z.r.txt == "h"