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

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

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

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

h = A("h")
g = B("g")
n = C("n")
e = D("e")
c = A("c")
l = C("l")
k = B("k")
i = A("i")

h.t = n
h.y = c
g.t = l
n.z = l
n.o = e
e.t = k
e.x = h
c.t = n
c.y = h
l.z = n
l.o = e
k.t = n
i.t = n
i.y = c
assert e.t.t.z.o.x.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.y: A = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
n = C("n")
e = D("e")
c = A("c")
l = C("l")
k = B("k")
i = A("i")

h.t = n
h.y = c
g.t = l
n.z = l
n.o = e
e.t = k
e.x = h
c.t = n
c.y = h
l.z = n
l.o = e
k.t = n
i.t = n
i.y = c
assert e.t.t.z.o.x.y.t.txt == "n"