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

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

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

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

d = A("d")
l = B("l")
g = C("g")
f = D("f")
i = B("i")
k = D("k")
n = C("n")
h = C("h")
b = C("b")

d.s = f
l.x = f
l.v = i
g.r = b
f.r = k
f.z = d
i.x = f
i.v = l
k.r = f
k.z = d
n.r = b
h.r = b
b.r = n
assert b.r.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

d = A("d")
l = B("l")
g = C("g")
f = D("f")
i = B("i")
k = D("k")
n = C("n")
h = C("h")
b = C("b")

d.s = f
l.x = f
l.v = i
g.r = b
f.r = k
f.z = d
i.x = f
i.v = l
k.r = f
k.z = d
n.r = b
h.r = b
b.r = n
assert b.r.r.r.r.r.r.r.r.txt == "b"