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

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

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

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

k = A("k")
n = B("n")
c = C("c")
a = D("a")
d = A("d")
l = B("l")
i = C("i")
f = D("f")
g = A("g")

k.u = a
k.s = c
k.r = c
n.y = d
n.w = i
n.z = i
n.x = g
c.t = n
c.q = n
c.p = f
c.y = f
a.s = f
d.u = f
d.s = c
d.r = i
l.y = g
l.w = i
l.z = c
l.x = d
i.t = l
i.q = l
i.p = f
i.y = f
f.s = a
g.u = f
g.s = c
g.r = c
assert f.s.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.s: C = None
        self.r: C = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
c = C("c")
a = D("a")
d = A("d")
l = B("l")
i = C("i")
f = D("f")
g = A("g")

k.u = a
k.s = c
k.r = c
n.y = d
n.w = i
n.z = i
n.x = g
c.t = n
c.q = n
c.p = f
c.y = f
a.s = f
d.u = f
d.s = c
d.r = i
l.y = g
l.w = i
l.z = c
l.x = d
i.t = l
i.q = l
i.p = f
i.y = f
f.s = a
g.u = f
g.s = c
g.r = c
assert f.s.s.s.s.s.s.s.txt == "a"