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

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

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

c = A("c")
k = B("k")
h = C("h")
f = B("f")

c.r = k
c.w = k
c.t = k
k.q = c
k.t = h
k.x = f
h.w = k
f.q = c
f.t = h
f.x = k
assert k.x.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.w: B = None
        self.t: B = None
        self.txt = txt

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

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

c = A("c")
k = B("k")
h = C("h")
f = B("f")

c.r = k
c.w = k
c.t = k
k.q = c
k.t = h
k.x = f
h.w = k
f.q = c
f.t = h
f.x = k
assert k.x.t.w.txt == "k"