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

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

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

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

f = A("f")
g = B("g")
a = C("a")
b = D("b")
m = A("m")
l = C("l")

f.s = m
f.w = m
f.q = m
g.v = f
g.q = l
a.z = g
a.u = b
a.y = f
b.t = l
b.x = a
b.v = g
b.w = f
m.s = f
m.w = f
m.q = f
l.z = g
l.u = b
l.y = m
assert g.v.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.w: A = None
        self.q: A = None
        self.txt = txt

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

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

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

f = A("f")
g = B("g")
a = C("a")
b = D("b")
m = A("m")
l = C("l")

f.s = m
f.w = m
f.q = m
g.v = f
g.q = l
a.z = g
a.u = b
a.y = f
b.t = l
b.x = a
b.v = g
b.w = f
m.s = f
m.w = f
m.q = f
l.z = g
l.u = b
l.y = m
assert g.v.w.s.txt == "f"