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

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

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

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

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

a.p = l
a.y = l
g.o = l
g.y = a
g.w = b
l.o = g
l.t = g
l.p = g
m.z = e
e.p = l
e.y = l
h.p = l
h.y = l
n.z = j
b.z = j
j.p = l
j.y = l
assert h.y.o.o.t.y.y.p.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: C = None
        self.txt = txt

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

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

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

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

a.p = l
a.y = l
g.o = l
g.y = a
g.w = b
l.o = g
l.t = g
l.p = g
m.z = e
e.p = l
e.y = l
h.p = l
h.y = l
n.z = j
b.z = j
j.p = l
j.y = l
assert h.y.o.o.t.y.y.p.o.o.txt == "g"