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

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

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

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

k = A("k")
n = B("n")
g = C("g")
a = D("a")
b = B("b")
m = C("m")
i = D("i")
l = B("l")

k.t = a
k.w = i
n.t = i
n.x = m
n.w = m
n.p = k
g.s = b
g.p = m
a.y = i
b.t = i
b.x = g
b.w = g
b.p = k
m.s = n
m.p = g
i.y = a
l.t = i
l.x = g
l.w = g
l.p = k
assert a.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.w: D = None
        self.txt = txt

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

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

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

k = A("k")
n = B("n")
g = C("g")
a = D("a")
b = B("b")
m = C("m")
i = D("i")
l = B("l")

k.t = a
k.w = i
n.t = i
n.x = m
n.w = m
n.p = k
g.s = b
g.p = m
a.y = i
b.t = i
b.x = g
b.w = g
b.p = k
m.s = n
m.p = g
i.y = a
l.t = i
l.x = g
l.w = g
l.p = k
assert a.y.y.y.txt == "i"