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

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.o: A = None
        self.w: A = None
        self.q: B = None
        self.txt = txt

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

g = A("g")
b = B("b")
f = C("f")
k = D("k")
d = D("d")

g.w = b
g.r = f
g.s = f
b.z = k
f.v = g
f.o = g
f.w = g
f.q = b
k.x = f
k.o = d
d.x = f
d.o = k
assert d.x.v.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: C = None
        self.s: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.o: A = None
        self.w: A = None
        self.q: B = None
        self.txt = txt

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

g = A("g")
b = B("b")
f = C("f")
k = D("k")
d = D("d")

g.w = b
g.r = f
g.s = f
b.z = k
f.v = g
f.o = g
f.w = g
f.q = b
k.x = f
k.o = d
d.x = f
d.o = k
assert d.x.v.r.w.r.txt == "f"