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

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

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

a = A("a")
b = B("b")
e = C("e")
j = C("j")
c = A("c")
g = B("g")

a.v = c
a.t = g
b.t = e
b.w = g
e.v = b
j.v = b
c.v = a
c.t = g
g.t = j
g.w = b
assert c.v.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: B = None
        self.txt = txt

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

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

a = A("a")
b = B("b")
e = C("e")
j = C("j")
c = A("c")
g = B("g")

a.v = c
a.t = g
b.t = e
b.w = g
e.v = b
j.v = b
c.v = a
c.t = g
g.t = j
g.w = b
assert c.v.t.t.txt == "j"