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

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: D = None
        self.txt = txt

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

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

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

d.v = n
i.p = g
i.v = j
f.p = i
j.s = a
j.y = a
j.v = d
j.p = i
g.p = i
g.v = m
k.p = i
n.p = i
c.v = n
a.v = f
m.s = c
m.v = c
m.p = g
m.y = d
assert i.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: D = None
        self.txt = txt

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

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

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

d.v = n
i.p = g
i.v = j
f.p = i
j.s = a
j.y = a
j.v = d
j.p = i
g.p = i
g.v = m
k.p = i
n.p = i
c.v = n
a.v = f
m.s = c
m.v = c
m.p = g
m.y = d
assert i.p.p.p.p.txt == "i"