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

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

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

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

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

g.z = h
g.x = h
g.o = f
g.q = e
c.y = b
c.z = b
c.x = n
h.w = g
h.o = c
h.x = c
h.v = e
n.o = b
n.r = g
b.z = h
b.x = h
b.o = i
b.q = c
i.o = g
i.r = b
f.o = g
f.r = g
e.y = b
e.x = f
e.z = g
assert g.z.w.o.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.o: D = None
        self.q: B = None
        self.x: C = None
        self.txt = txt

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

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

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

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

g.z = h
g.x = h
g.o = f
g.q = e
c.y = b
c.z = b
c.x = n
h.w = g
h.o = c
h.x = c
h.v = e
n.o = b
n.r = g
b.z = h
b.x = h
b.o = i
b.q = c
i.o = g
i.r = b
f.o = g
f.r = g
e.y = b
e.x = f
e.z = g
assert g.z.w.o.r.o.r.txt == "g"