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

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

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

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

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

g.s = b
k.t = n
k.q = n
f.u = a
f.o = a
f.s = n
f.q = b
n.y = g
n.s = k
n.w = a
n.p = a
a.u = f
a.o = f
a.s = n
a.q = b
b.s = g
assert a.s.w.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

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

g.s = b
k.t = n
k.q = n
f.u = a
f.o = a
f.s = n
f.q = b
n.y = g
n.s = k
n.w = a
n.p = a
a.u = f
a.o = f
a.s = n
a.q = b
b.s = g
assert a.s.w.s.y.txt == "g"