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

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

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

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

d = A("d")
j = B("j")
k = C("k")
e = D("e")
b = D("b")

d.w = j
d.p = k
d.t = k
j.x = k
k.x = d
k.y = d
k.w = b
e.q = k
e.z = b
e.s = b
b.q = k
b.z = e
b.s = e
assert e.q.y.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.p: C = None
        self.t: C = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
k = C("k")
e = D("e")
b = D("b")

d.w = j
d.p = k
d.t = k
j.x = k
k.x = d
k.y = d
k.w = b
e.q = k
e.z = b
e.s = b
b.q = k
b.z = e
b.s = e
assert e.q.y.w.x.txt == "k"