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

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: C = None
        self.r: A = None
        self.y: B = None
        self.txt = txt

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

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

n = A("n")
f = B("f")
c = C("c")
m = D("m")
b = C("b")
h = A("h")
d = D("d")
e = A("e")
a = B("a")

n.z = b
n.o = b
n.q = e
f.t = c
f.u = c
f.r = n
f.y = a
c.t = e
m.x = c
m.z = a
m.y = a
b.t = n
h.z = b
h.q = e
h.o = c
d.x = b
d.z = f
d.y = a
e.z = c
e.q = n
e.o = b
a.t = b
a.u = b
a.r = e
a.y = f
assert d.x.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: A = None
        self.o: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: C = None
        self.r: A = None
        self.y: B = None
        self.txt = txt

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

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

n = A("n")
f = B("f")
c = C("c")
m = D("m")
b = C("b")
h = A("h")
d = D("d")
e = A("e")
a = B("a")

n.z = b
n.o = b
n.q = e
f.t = c
f.u = c
f.r = n
f.y = a
c.t = e
m.x = c
m.z = a
m.y = a
b.t = n
h.z = b
h.q = e
h.o = c
d.x = b
d.z = f
d.y = a
e.z = c
e.q = n
e.o = b
a.t = b
a.u = b
a.r = e
a.y = f
assert d.x.t.o.txt == "b"