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

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

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

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

g = A("g")
d = B("d")
c = C("c")
e = D("e")
k = B("k")
i = C("i")
a = D("a")
f = B("f")
h = C("h")

g.p = h
g.x = h
d.u = h
d.o = g
d.p = f
d.x = a
c.p = g
e.s = i
e.o = a
e.y = a
e.q = h
k.u = i
k.o = g
k.p = f
k.x = a
i.p = g
a.s = c
a.o = e
a.y = e
a.q = i
f.u = h
f.o = g
f.p = k
f.x = a
h.p = g
assert a.q.p.x.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: C = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
c = C("c")
e = D("e")
k = B("k")
i = C("i")
a = D("a")
f = B("f")
h = C("h")

g.p = h
g.x = h
d.u = h
d.o = g
d.p = f
d.x = a
c.p = g
e.s = i
e.o = a
e.y = a
e.q = h
k.u = i
k.o = g
k.p = f
k.x = a
i.p = g
a.s = c
a.o = e
a.y = e
a.q = i
f.u = h
f.o = g
f.p = k
f.x = a
h.p = g
assert a.q.p.x.p.p.p.p.txt == "h"