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

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

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

d = A("d")
l = B("l")
k = C("k")
g = A("g")

d.v = l
l.x = k
k.v = g
k.p = g
k.u = d
g.v = l
assert l.x.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

d = A("d")
l = B("l")
k = C("k")
g = A("g")

d.v = l
l.x = k
k.v = g
k.p = g
k.u = d
g.v = l
assert l.x.v.v.txt == "l"