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

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

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

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

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

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

l = A("l")
h = B("h")
d = C("d")
b = D("b")
m = E("m")
j = F("j")
a = E("a")
i = D("i")

l.x = b
l.y = i
l.s = d
l.z = h
h.z = l
d.t = h
b.s = a
b.z = d
b.y = h
b.o = m
m.q = b
m.x = d
j.x = l
a.q = b
a.x = d
i.s = m
i.o = m
i.z = d
i.y = h
assert m.q.s.x.t.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: D = None
        self.s: C = None
        self.z: B = None
        self.txt = txt

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

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

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

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

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

l = A("l")
h = B("h")
d = C("d")
b = D("b")
m = E("m")
j = F("j")
a = E("a")
i = D("i")

l.x = b
l.y = i
l.s = d
l.z = h
h.z = l
d.t = h
b.s = a
b.z = d
b.y = h
b.o = m
m.q = b
m.x = d
j.x = l
a.q = b
a.x = d
i.s = m
i.o = m
i.z = d
i.y = h
assert m.q.s.x.t.z.z.z.z.txt == "h"