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

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

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

n = A("n")
c = B("c")
g = C("g")
d = A("d")
b = B("b")

n.v = g
n.u = g
c.z = b
c.t = g
c.r = d
g.t = d
d.v = g
d.u = g
b.z = c
b.t = g
b.r = d
assert b.z.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.u: C = None
        self.txt = txt

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

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

n = A("n")
c = B("c")
g = C("g")
d = A("d")
b = B("b")

n.v = g
n.u = g
c.z = b
c.t = g
c.r = d
g.t = d
d.v = g
d.u = g
b.z = c
b.t = g
b.r = d
assert b.z.z.t.txt == "g"