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

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

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

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

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

c.v = f
k.p = c
k.o = g
g.q = f
g.t = k
g.x = k
g.s = c
f.o = c
f.t = c
f.u = k
assert k.o.t.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

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

c.v = f
k.p = c
k.o = g
g.q = f
g.t = k
g.x = k
g.s = c
f.o = c
f.t = c
f.u = k
assert k.o.t.o.s.txt == "c"