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

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

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

g = A("g")
b = B("b")
f = C("f")
i = B("i")

g.p = i
g.u = f
b.v = f
b.s = i
b.t = g
f.q = b
i.v = f
i.s = b
i.t = g
assert b.s.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: C = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
f = C("f")
i = B("i")

g.p = i
g.u = f
b.v = f
b.s = i
b.t = g
f.q = b
i.v = f
i.s = b
i.t = g
assert b.s.v.q.txt == "b"