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

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

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

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

b = A("b")
d = B("d")
j = C("j")
g = D("g")
h = B("h")
n = C("n")
i = D("i")

b.p = n
d.z = b
d.t = i
j.s = h
j.w = d
j.x = d
j.o = n
g.p = i
g.z = b
g.v = h
g.w = n
h.z = b
h.t = i
n.s = h
n.w = d
n.x = d
n.o = j
i.p = g
i.z = b
i.v = h
i.w = n
assert d.t.w.s.z.p.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

b = A("b")
d = B("d")
j = C("j")
g = D("g")
h = B("h")
n = C("n")
i = D("i")

b.p = n
d.z = b
d.t = i
j.s = h
j.w = d
j.x = d
j.o = n
g.p = i
g.z = b
g.v = h
g.w = n
h.z = b
h.t = i
n.s = h
n.w = d
n.x = d
n.o = j
i.p = g
i.z = b
i.v = h
i.w = n
assert d.t.w.s.z.p.s.t.txt == "i"