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

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

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

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

l = A("l")
a = B("a")
g = C("g")
h = D("h")
e = A("e")
d = B("d")
i = D("i")

l.o = i
l.q = d
l.w = h
l.x = a
a.q = g
g.u = d
g.q = i
h.y = l
e.o = h
e.w = h
e.q = d
e.x = d
d.q = g
i.y = e
assert d.q.u.q.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.q: B = None
        self.w: D = None
        self.x: B = None
        self.txt = txt

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

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

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

l = A("l")
a = B("a")
g = C("g")
h = D("h")
e = A("e")
d = B("d")
i = D("i")

l.o = i
l.q = d
l.w = h
l.x = a
a.q = g
g.u = d
g.q = i
h.y = l
e.o = h
e.w = h
e.q = d
e.x = d
d.q = g
i.y = e
assert d.q.u.q.q.y.txt == "e"