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

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: C = None
        self.u: C = None
        self.txt = txt

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

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

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

b.o = g
b.s = d
b.t = n
g.q = n
g.z = a
g.u = a
a.w = k
a.y = f
h.r = f
f.r = d
d.r = h
k.q = g
k.z = a
k.u = a
n.q = g
n.z = a
n.u = a
assert a.y.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: D = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: C = None
        self.u: C = None
        self.txt = txt

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

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

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

b.o = g
b.s = d
b.t = n
g.q = n
g.z = a
g.u = a
a.w = k
a.y = f
h.r = f
f.r = d
d.r = h
k.q = g
k.z = a
k.u = a
n.q = g
n.z = a
n.u = a
assert a.y.r.r.r.r.r.txt == "h"