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

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

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

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

j = A("j")
g = B("g")
a = C("a")
b = D("b")
i = D("i")

j.p = g
j.u = g
g.p = a
a.w = i
a.y = i
a.r = i
a.v = g
b.u = i
b.s = g
b.q = a
b.y = j
i.u = b
i.s = g
i.q = a
i.y = j
assert b.q.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: B = None
        self.txt = txt

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

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

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

j = A("j")
g = B("g")
a = C("a")
b = D("b")
i = D("i")

j.p = g
j.u = g
g.p = a
a.w = i
a.y = i
a.r = i
a.v = g
b.u = i
b.s = g
b.q = a
b.y = j
i.u = b
i.s = g
i.q = a
i.y = j
assert b.q.w.s.txt == "g"