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

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

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

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

g = A("g")
i = B("i")
d = C("d")
h = D("h")
k = C("k")
m = B("m")
a = B("a")

g.p = k
i.r = a
i.v = a
i.o = g
i.t = m
d.p = k
d.o = k
d.t = a
d.y = h
h.w = k
k.p = d
k.o = d
k.t = i
k.y = h
m.r = i
m.v = a
m.t = a
m.o = g
a.r = i
a.v = i
a.o = g
a.t = m
assert d.p.y.w.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
d = C("d")
h = D("h")
k = C("k")
m = B("m")
a = B("a")

g.p = k
i.r = a
i.v = a
i.o = g
i.t = m
d.p = k
d.o = k
d.t = a
d.y = h
h.w = k
k.p = d
k.o = d
k.t = i
k.y = h
m.r = i
m.v = a
m.t = a
m.o = g
a.r = i
a.v = i
a.o = g
a.t = m
assert d.p.y.w.y.w.y.txt == "h"