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

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.w: A = None
        self.v: A = None
        self.txt = txt

k = A("k")
g = B("g")
c = C("c")
n = D("n")

k.o = g
k.u = g
g.x = n
g.q = n
g.z = k
g.o = c
c.t = k
c.w = n
n.x = c
n.w = k
n.v = k
assert g.z.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.w: A = None
        self.v: A = None
        self.txt = txt

k = A("k")
g = B("g")
c = C("c")
n = D("n")

k.o = g
k.u = g
g.x = n
g.q = n
g.z = k
g.o = c
c.t = k
c.w = n
n.x = c
n.w = k
n.v = k
assert g.z.o.o.txt == "c"