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

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

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

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

i = A("i")
n = B("n")
j = C("j")
f = D("f")
g = C("g")
a = D("a")
b = C("b")
h = B("h")
e = B("e")
m = D("m")

i.s = g
n.s = i
n.r = i
j.r = b
j.y = b
j.p = i
j.o = i
f.y = b
g.r = j
g.p = i
g.o = i
g.y = b
a.y = j
b.r = j
b.p = i
b.o = i
b.y = g
h.s = i
h.r = i
e.s = i
e.r = i
m.y = g
assert f.y.y.y.o.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

i = A("i")
n = B("n")
j = C("j")
f = D("f")
g = C("g")
a = D("a")
b = C("b")
h = B("h")
e = B("e")
m = D("m")

i.s = g
n.s = i
n.r = i
j.r = b
j.y = b
j.p = i
j.o = i
f.y = b
g.r = j
g.p = i
g.o = i
g.y = b
a.y = j
b.r = j
b.p = i
b.o = i
b.y = g
h.s = i
h.r = i
e.s = i
e.r = i
m.y = g
assert f.y.y.y.o.s.p.txt == "i"