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

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

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

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

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

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

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

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

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

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

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