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

class B:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: B = None
        self.s: D = None
        self.t: D = None
        self.txt = txt

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

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

m = A("m")
n = B("n")
i = C("i")
g = D("g")
k = B("k")
e = A("e")

m.p = n
m.x = e
m.v = g
m.s = g
n.x = k
n.p = k
n.s = g
n.t = g
i.o = g
i.p = e
g.x = n
g.y = n
g.o = k
k.x = n
k.p = n
k.s = g
k.t = g
e.p = k
e.x = m
e.v = g
e.s = g
assert e.p.s.y.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.x: A = None
        self.v: D = None
        self.s: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: B = None
        self.s: D = None
        self.t: D = None
        self.txt = txt

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

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

m = A("m")
n = B("n")
i = C("i")
g = D("g")
k = B("k")
e = A("e")

m.p = n
m.x = e
m.v = g
m.s = g
n.x = k
n.p = k
n.s = g
n.t = g
i.o = g
i.p = e
g.x = n
g.y = n
g.o = k
k.x = n
k.p = n
k.s = g
k.t = g
e.p = k
e.x = m
e.v = g
e.s = g
assert e.p.s.y.p.s.txt == "g"