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

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

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

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

n = A("n")
g = B("g")
j = C("j")
a = D("a")

n.p = j
n.t = j
g.q = j
g.r = j
g.y = a
j.o = n
j.v = g
j.x = g
j.u = g
a.u = g
a.y = g
a.t = j
a.q = j
assert g.q.o.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.t: C = None
        self.txt = txt

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

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

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

n = A("n")
g = B("g")
j = C("j")
a = D("a")

n.p = j
n.t = j
g.q = j
g.r = j
g.y = a
j.o = n
j.v = g
j.x = g
j.u = g
a.u = g
a.y = g
a.t = j
a.q = j
assert g.q.o.t.o.txt == "n"