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

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

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

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

g = A("g")
e = B("e")
h = C("h")
l = D("l")

g.s = e
g.y = e
g.u = h
e.s = h
e.t = h
e.p = l
e.q = l
h.q = g
h.x = g
h.p = e
h.v = l
l.x = h
l.s = h
l.y = e
l.w = e
assert h.p.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: C = None
        self.y: B = None
        self.txt = txt

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

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

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

g = A("g")
e = B("e")
h = C("h")
l = D("l")

g.s = e
g.y = e
g.u = h
e.s = h
e.t = h
e.p = l
e.q = l
h.q = g
h.x = g
h.p = e
h.v = l
l.x = h
l.s = h
l.y = e
l.w = e
assert h.p.q.x.txt == "h"