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

class B:
    def __init__(self, txt: str):
        self.o: C = 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.p: B = None
        self.s: B = None
        self.x: B = None
        self.txt = txt

b = A("b")
c = B("c")
l = C("l")
d = D("d")
k = C("k")
a = A("a")
f = D("f")
g = C("g")

b.z = c
c.o = l
l.r = k
d.p = c
d.s = c
d.x = c
k.r = g
a.z = c
f.p = c
f.s = c
f.x = c
g.r = l
assert g.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = 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.p: B = None
        self.s: B = None
        self.x: B = None
        self.txt = txt

b = A("b")
c = B("c")
l = C("l")
d = D("d")
k = C("k")
a = A("a")
f = D("f")
g = C("g")

b.z = c
c.o = l
l.r = k
d.p = c
d.s = c
d.x = c
k.r = g
a.z = c
f.p = c
f.s = c
f.x = c
g.r = l
assert g.r.r.r.r.r.r.txt == "g"