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

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

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

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

h = A("h")
f = B("f")
b = C("b")
a = D("a")
j = C("j")
c = A("c")
e = C("e")
n = C("n")
g = D("g")

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

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

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

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

h = A("h")
f = B("f")
b = C("b")
a = D("a")
j = C("j")
c = A("c")
e = C("e")
n = C("n")
g = D("g")

h.p = j
h.z = n
f.q = g
f.y = c
f.z = j
b.y = h
b.o = h
b.w = g
a.q = h
j.y = h
j.o = h
j.w = a
c.p = e
c.z = b
e.y = h
e.o = h
e.w = g
n.y = h
n.o = h
n.w = a
g.q = h
assert e.y.z.y.z.o.txt == "h"