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

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

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

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

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

d.v = h
d.s = k
m.p = g
m.y = k
m.t = k
m.x = n
b.t = k
e.w = g
e.x = g
e.t = h
e.p = b
n.t = k
l.w = g
l.t = h
l.p = n
l.x = d
k.p = d
k.y = m
k.t = m
k.x = n
c.w = g
c.x = g
c.t = b
c.p = h
h.t = k
g.v = n
g.s = k
assert n.t.x.t.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: B = None
        self.txt = txt

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

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

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

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

d.v = h
d.s = k
m.p = g
m.y = k
m.t = k
m.x = n
b.t = k
e.w = g
e.x = g
e.t = h
e.p = b
n.t = k
l.w = g
l.t = h
l.p = n
l.x = d
k.p = d
k.y = m
k.t = m
k.x = n
c.w = g
c.x = g
c.t = b
c.p = h
h.t = k
g.v = n
g.s = k
assert n.t.x.t.p.s.txt == "k"