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

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

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

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

c = A("c")
m = B("m")
f = C("f")
j = D("j")
n = D("n")
l = B("l")
h = A("h")
i = D("i")
b = A("b")

c.x = m
c.v = f
c.s = h
m.t = n
f.p = l
f.x = n
f.y = b
j.z = n
j.s = m
n.z = j
n.s = m
l.t = j
h.x = l
h.v = f
h.s = c
i.z = j
i.s = m
b.x = m
b.v = f
b.s = c
assert m.t.s.t.s.t.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.v: C = None
        self.s: A = None
        self.txt = txt

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

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

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

c = A("c")
m = B("m")
f = C("f")
j = D("j")
n = D("n")
l = B("l")
h = A("h")
i = D("i")
b = A("b")

c.x = m
c.v = f
c.s = h
m.t = n
f.p = l
f.x = n
f.y = b
j.z = n
j.s = m
n.z = j
n.s = m
l.t = j
h.x = l
h.v = f
h.s = c
i.z = j
i.s = m
b.x = m
b.v = f
b.s = c
assert m.t.s.t.s.t.s.t.txt == "n"