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

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

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

k = A("k")
e = B("e")
m = C("m")
f = B("f")
j = C("j")
c = A("c")
d = C("d")

k.w = c
k.v = m
k.r = m
e.z = f
m.t = e
f.z = e
j.t = e
c.w = k
c.v = d
c.r = d
d.t = e
assert k.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: C = None
        self.r: C = None
        self.txt = txt

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

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

k = A("k")
e = B("e")
m = C("m")
f = B("f")
j = C("j")
c = A("c")
d = C("d")

k.w = c
k.v = m
k.r = m
e.z = f
m.t = e
f.z = e
j.t = e
c.w = k
c.v = d
c.r = d
d.t = e
assert k.w.w.w.w.w.w.txt == "k"