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

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

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

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

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

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

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

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

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

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

b.s = d
f.o = n
f.x = n
f.t = b
f.p = g
n.y = h
n.r = h
n.s = a
a.x = d
a.t = b
a.z = c
k.o = h
k.x = h
k.t = b
k.p = a
d.x = a
d.t = b
d.z = c
h.y = n
h.r = n
h.s = g
c.o = h
c.t = b
c.x = n
c.p = d
g.x = d
g.t = b
g.z = k
assert h.r.y.r.s.x.t.s.t.s.txt == "d"