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

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

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

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

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

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

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

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

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

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

g.x = n
g.z = c
g.y = c
g.s = h
j.s = g
j.z = n
j.w = n
e.z = n
h.p = n
h.o = j
h.z = c
n.p = h
n.o = j
n.z = c
c.z = n
assert g.y.z.o.txt == "j"