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

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

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

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

e = A("e")
l = B("l")
c = C("c")
g = D("g")
b = A("b")
m = D("m")
f = A("f")
n = C("n")
d = A("d")
i = A("i")

e.t = l
l.w = d
l.r = e
c.z = b
g.r = d
g.o = m
g.s = l
g.x = f
b.t = l
m.r = f
m.o = g
m.s = l
m.x = d
f.t = l
n.z = b
d.t = l
i.t = l
assert e.t.r.t.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

e = A("e")
l = B("l")
c = C("c")
g = D("g")
b = A("b")
m = D("m")
f = A("f")
n = C("n")
d = A("d")
i = A("i")

e.t = l
l.w = d
l.r = e
c.z = b
g.r = d
g.o = m
g.s = l
g.x = f
b.t = l
m.r = f
m.o = g
m.s = l
m.x = d
f.t = l
n.z = b
d.t = l
i.t = l
assert e.t.r.t.r.t.r.txt == "e"