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

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

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

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

i = A("i")
c = B("c")
f = C("f")
n = D("n")
m = C("m")
l = D("l")
g = B("g")

i.o = n
c.r = l
c.x = l
c.s = f
c.y = g
f.r = l
f.w = c
f.o = i
n.p = i
n.w = i
n.o = g
m.r = l
m.w = c
m.o = i
l.p = i
l.w = i
l.o = c
g.r = l
g.x = l
g.s = m
g.y = c
assert i.o.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

i = A("i")
c = B("c")
f = C("f")
n = D("n")
m = C("m")
l = D("l")
g = B("g")

i.o = n
c.r = l
c.x = l
c.s = f
c.y = g
f.r = l
f.w = c
f.o = i
n.p = i
n.w = i
n.o = g
m.r = l
m.w = c
m.o = i
l.p = i
l.w = i
l.o = c
g.r = l
g.x = l
g.s = m
g.y = c
assert i.o.o.s.txt == "m"