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

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

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

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

f = A("f")
d = B("d")
e = C("e")
i = D("i")
a = D("a")
c = B("c")
n = D("n")
g = C("g")

f.u = i
d.t = a
d.x = a
d.s = i
d.p = i
e.t = d
e.y = c
i.r = c
a.r = d
c.t = a
c.s = n
c.p = n
c.x = n
n.r = d
g.t = d
g.y = c
assert c.t.r.s.r.x.r.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
e = C("e")
i = D("i")
a = D("a")
c = B("c")
n = D("n")
g = C("g")

f.u = i
d.t = a
d.x = a
d.s = i
d.p = i
e.t = d
e.y = c
i.r = c
a.r = d
c.t = a
c.s = n
c.p = n
c.x = n
n.r = d
g.t = d
g.y = c
assert c.t.r.s.r.x.r.x.r.txt == "d"