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

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

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

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

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

n.o = c
n.p = c
c.p = n
c.y = n
f.u = b
i.q = n
g.q = n
b.q = n
assert f.u.q.p.p.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: B = None
        self.txt = txt

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

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

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

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

n.o = c
n.p = c
c.p = n
c.y = n
f.u = b
i.q = n
g.q = n
b.q = n
assert f.u.q.p.p.o.y.txt == "n"