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

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

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

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

j = A("j")
c = B("c")
b = C("b")
i = D("i")
f = C("f")
k = C("k")
g = D("g")
n = B("n")

j.z = b
c.y = n
b.x = f
i.s = k
f.x = k
k.x = b
g.s = b
n.y = c
assert c.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

j = A("j")
c = B("c")
b = C("b")
i = D("i")
f = C("f")
k = C("k")
g = D("g")
n = B("n")

j.z = b
c.y = n
b.x = f
i.s = k
f.x = k
k.x = b
g.s = b
n.y = c
assert c.y.y.y.y.y.txt == "n"