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

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

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: A = None
        self.y: C = None
        self.p: C = None
        self.txt = txt

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

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

g.w = j
g.s = j
g.t = d
g.q = i
j.p = d
j.z = d
j.s = i
j.v = i
i.x = d
i.r = g
i.y = a
i.p = a
d.s = j
a.x = d
a.r = g
a.y = i
a.p = i
assert j.v.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.s: B = None
        self.t: D = None
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: A = None
        self.y: C = None
        self.p: C = None
        self.txt = txt

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

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

g.w = j
g.s = j
g.t = d
g.q = i
j.p = d
j.z = d
j.s = i
j.v = i
i.x = d
i.r = g
i.y = a
i.p = a
d.s = j
a.x = d
a.r = g
a.y = i
a.p = i
assert j.v.r.t.txt == "d"