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

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

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

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

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

l.t = c
l.z = g
d.r = c
a.s = g
a.x = g
a.u = d
g.y = c
g.t = d
g.s = l
i.s = g
i.x = g
i.u = c
e.s = g
e.x = g
e.u = d
c.r = d
m.s = g
m.x = g
m.u = d
assert i.u.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: D = None
        self.txt = txt

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

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

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

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

l.t = c
l.z = g
d.r = c
a.s = g
a.x = g
a.u = d
g.y = c
g.t = d
g.s = l
i.s = g
i.x = g
i.u = c
e.s = g
e.x = g
e.u = d
c.r = d
m.s = g
m.x = g
m.u = d
assert i.u.r.r.r.r.r.txt == "d"