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

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: C = None
        self.y: A = None
        self.txt = txt

j = A("j")
i = B("i")
e = C("e")
n = A("n")
m = C("m")
d = B("d")
b = C("b")

j.s = d
j.p = i
j.t = m
i.z = j
i.x = j
i.r = n
e.r = j
e.y = j
e.w = b
n.s = i
n.p = i
n.t = b
m.r = j
m.y = j
m.w = b
d.z = n
d.r = j
d.x = j
b.r = j
b.y = j
b.w = e
assert m.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: B = None
        self.t: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: C = None
        self.y: A = None
        self.txt = txt

j = A("j")
i = B("i")
e = C("e")
n = A("n")
m = C("m")
d = B("d")
b = C("b")

j.s = d
j.p = i
j.t = m
i.z = j
i.x = j
i.r = n
e.r = j
e.y = j
e.w = b
n.s = i
n.p = i
n.t = b
m.r = j
m.y = j
m.w = b
d.z = n
d.r = j
d.x = j
b.r = j
b.y = j
b.w = e
assert m.w.w.w.txt == "b"