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

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

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

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

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

g.w = l
g.z = a
g.q = i
l.o = f
f.w = a
f.y = l
f.x = b
f.o = b
a.q = b
a.v = g
i.w = l
i.z = a
i.q = g
b.w = a
b.y = l
b.x = f
b.o = f
assert l.o.x.o.y.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.z: D = None
        self.q: A = None
        self.txt = txt

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

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

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

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

g.w = l
g.z = a
g.q = i
l.o = f
f.w = a
f.y = l
f.x = b
f.o = b
a.q = b
a.v = g
i.w = l
i.z = a
i.q = g
b.w = a
b.y = l
b.x = f
b.o = f
assert l.o.x.o.y.o.w.txt == "a"