class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: B = None
        self.x: B = None
        self.txt = txt

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

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

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

b = A("b")
g = B("g")
a = C("a")
l = D("l")
e = A("e")
d = B("d")
n = D("n")
h = B("h")

b.r = h
b.u = d
b.x = d
g.p = d
a.q = h
a.z = g
a.w = l
l.s = a
l.t = a
l.u = b
l.y = e
e.r = h
e.u = g
e.x = d
d.p = g
n.s = a
n.t = a
n.u = e
n.y = b
h.p = g
assert d.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: B = None
        self.x: B = None
        self.txt = txt

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

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

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

b = A("b")
g = B("g")
a = C("a")
l = D("l")
e = A("e")
d = B("d")
n = D("n")
h = B("h")

b.r = h
b.u = d
b.x = d
g.p = d
a.q = h
a.z = g
a.w = l
l.s = a
l.t = a
l.u = b
l.y = e
e.r = h
e.u = g
e.x = d
d.p = g
n.s = a
n.t = a
n.u = e
n.y = b
h.p = g
assert d.p.p.p.p.txt == "d"