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

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: A = None
        self.t: C = None
        self.z: A = None
        self.txt = txt

e = A("e")
f = B("f")
c = C("c")
g = D("g")

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

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: A = None
        self.t: C = None
        self.z: A = None
        self.txt = txt

e = A("e")
f = B("f")
c = C("c")
g = D("g")

e.s = f
e.x = f
e.r = c
e.o = g
f.s = e
f.z = e
f.t = g
f.w = c
c.q = e
c.s = e
g.v = c
g.t = c
g.r = e
g.z = e
assert g.v.s.x.txt == "f"