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

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

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

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

n = A("n")
k = B("k")
l = C("l")
e = D("e")
b = A("b")
c = B("c")
j = B("j")
f = A("f")
i = C("i")

n.s = k
k.o = b
k.r = i
k.q = f
k.z = e
l.z = b
l.x = c
l.r = i
l.w = i
e.q = i
b.s = c
c.o = n
c.r = i
c.q = f
c.z = e
j.o = f
j.q = f
j.r = i
j.z = e
f.s = c
i.z = b
i.x = c
i.r = l
i.w = l
assert e.q.z.s.o.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

n = A("n")
k = B("k")
l = C("l")
e = D("e")
b = A("b")
c = B("c")
j = B("j")
f = A("f")
i = C("i")

n.s = k
k.o = b
k.r = i
k.q = f
k.z = e
l.z = b
l.x = c
l.r = i
l.w = i
e.q = i
b.s = c
c.o = n
c.r = i
c.q = f
c.z = e
j.o = f
j.q = f
j.r = i
j.z = e
f.s = c
i.z = b
i.x = c
i.r = l
i.w = l
assert e.q.z.s.o.s.q.txt == "f"