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

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

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

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

c.t = k
n.p = k
n.x = k
n.u = c
k.v = c
k.u = c
k.y = c
assert c.t.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

c.t = k
n.p = k
n.x = k
n.u = c
k.v = c
k.u = c
k.y = c
assert c.t.v.t.txt == "k"