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

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

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

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

h = A("h")
g = B("g")
m = C("m")
k = D("k")
j = A("j")
f = D("f")
d = A("d")
l = C("l")
e = B("e")

h.y = g
h.r = k
h.x = j
g.r = e
g.p = e
m.o = k
m.t = f
m.q = e
m.s = h
k.z = f
k.q = f
j.y = g
j.r = k
j.x = h
f.z = k
f.q = k
d.y = e
d.r = k
d.x = h
l.o = k
l.t = k
l.q = g
l.s = h
e.r = g
e.p = g
assert e.r.r.r.p.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.r: D = None
        self.x: A = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
m = C("m")
k = D("k")
j = A("j")
f = D("f")
d = A("d")
l = C("l")
e = B("e")

h.y = g
h.r = k
h.x = j
g.r = e
g.p = e
m.o = k
m.t = f
m.q = e
m.s = h
k.z = f
k.q = f
j.y = g
j.r = k
j.x = h
f.z = k
f.q = k
d.y = e
d.r = k
d.x = h
l.o = k
l.t = k
l.q = g
l.s = h
e.r = g
e.p = g
assert e.r.r.r.p.r.r.r.txt == "g"