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

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

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

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: A = None
        self.txt = txt

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

n.r = g
n.s = g
n.w = g
n.t = a
k.u = g
k.w = n
k.s = n
a.o = n
a.x = m
g.o = n
g.y = n
m.u = g
m.w = n
m.s = n
b.o = n
b.x = m
assert b.x.u.y.s.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.t: C = None
        self.s: D = None
        self.w: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: A = None
        self.txt = txt

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

n.r = g
n.s = g
n.w = g
n.t = a
k.u = g
k.w = n
k.s = n
a.o = n
a.x = m
g.o = n
g.y = n
m.u = g
m.w = n
m.s = n
b.o = n
b.x = m
assert b.x.u.y.s.y.t.txt == "a"