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

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

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

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

e = A("e")
g = B("g")
h = C("h")
d = D("d")
i = A("i")
j = B("j")

e.s = j
g.p = e
g.x = j
g.w = h
h.p = d
h.x = g
h.q = j
d.x = j
i.s = j
j.p = i
j.x = g
j.w = h
assert g.x.w.q.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

e = A("e")
g = B("g")
h = C("h")
d = D("d")
i = A("i")
j = B("j")

e.s = j
g.p = e
g.x = j
g.w = h
h.p = d
h.x = g
h.q = j
d.x = j
i.s = j
j.p = i
j.x = g
j.w = h
assert g.x.w.q.p.s.txt == "j"