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

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

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

g = A("g")
e = B("e")
b = C("b")
n = C("n")
f = A("f")
h = B("h")

g.q = e
g.t = h
g.w = f
e.z = n
e.t = h
e.q = g
b.x = g
b.w = n
b.r = n
n.x = g
n.w = b
n.r = b
f.q = h
f.t = h
f.w = g
h.z = b
h.t = e
h.q = f
assert g.t.z.x.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.t: B = None
        self.w: A = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
b = C("b")
n = C("n")
f = A("f")
h = B("h")

g.q = e
g.t = h
g.w = f
e.z = n
e.t = h
e.q = g
b.x = g
b.w = n
b.r = n
n.x = g
n.w = b
n.r = b
f.q = h
f.t = h
f.w = g
h.z = b
h.t = e
h.q = f
assert g.t.z.x.w.w.txt == "g"