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

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

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

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

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

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

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

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

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

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

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