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

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

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

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

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

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

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

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

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

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

d.t = g
d.o = g
d.u = i
h.o = i
e.q = l
i.y = e
l.o = i
g.t = d
g.o = d
g.u = i
assert i.y.q.o.y.txt == "e"