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

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

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

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

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

c.o = e
c.s = m
c.u = a
f.s = c
n.u = a
n.z = a
n.q = m
e.z = f
e.r = f
e.p = c
a.u = n
a.z = n
a.q = m
m.z = f
m.r = f
m.p = c
assert e.p.o.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: D = None
        self.u: C = None
        self.txt = txt

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

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

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

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

c.o = e
c.s = m
c.u = a
f.s = c
n.u = a
n.z = a
n.q = m
e.z = f
e.r = f
e.p = c
a.u = n
a.z = n
a.q = m
m.z = f
m.r = f
m.p = c
assert e.p.o.r.s.txt == "c"