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

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

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

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

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

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

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

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

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

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

n.x = f
n.t = l
e.x = c
l.s = n
f.o = g
f.t = e
c.s = g
g.x = f
g.t = c
i.x = c
h.o = g
h.t = e
assert f.o.x.t.x.s.x.txt == "f"