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

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

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

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

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

c.w = b
c.o = b
c.r = k
j.o = k
j.s = d
k.x = j
g.q = n
g.y = c
d.q = g
d.y = c
b.x = a
f.x = j
n.q = g
n.y = c
a.o = b
a.s = g
assert f.x.s.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.o: C = None
        self.r: C = None
        self.txt = txt

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

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

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

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

c.w = b
c.o = b
c.r = k
j.o = k
j.s = d
k.x = j
g.q = n
g.y = c
d.q = g
d.y = c
b.x = a
f.x = j
n.q = g
n.y = c
a.o = b
a.s = g
assert f.x.s.q.q.txt == "n"