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

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.z: A = None
        self.q: C = None
        self.txt = txt

b = A("b")
g = B("g")
f = C("f")
j = C("j")
n = B("n")

b.r = f
g.x = b
g.v = b
g.p = j
f.w = b
f.z = b
f.q = j
j.w = b
j.z = b
j.q = f
n.x = b
n.v = b
n.p = f
assert b.r.q.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.z: A = None
        self.q: C = None
        self.txt = txt

b = A("b")
g = B("g")
f = C("f")
j = C("j")
n = B("n")

b.r = f
g.x = b
g.v = b
g.p = j
f.w = b
f.z = b
f.q = j
j.w = b
j.z = b
j.q = f
n.x = b
n.v = b
n.p = f
assert b.r.q.q.z.txt == "b"