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

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

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

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

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

d.x = b
n.s = g
n.r = a
n.u = e
c.s = e
a.s = b
b.x = d
l.s = d
g.s = b
e.s = c
assert g.s.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

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

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

d.x = b
n.s = g
n.r = a
n.u = e
c.s = e
a.s = b
b.x = d
l.s = d
g.s = b
e.s = c
assert g.s.x.x.x.x.x.x.x.txt == "d"