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

class B:
    def __init__(self, txt: str):
        self.q: F = None
        self.s: D = None
        self.x: F = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
k = C("k")
h = D("h")
g = E("g")
m = F("m")

f.w = d
f.x = d
f.t = h
d.q = m
d.x = m
d.s = h
k.w = f
k.q = h
k.r = m
h.p = k
g.w = k
g.u = k
m.q = f
m.z = f
assert k.r.q.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: B = None
        self.t: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: F = None
        self.s: D = None
        self.x: F = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

f = A("f")
d = B("d")
k = C("k")
h = D("h")
g = E("g")
m = F("m")

f.w = d
f.x = d
f.t = h
d.q = m
d.x = m
d.s = h
k.w = f
k.q = h
k.r = m
h.p = k
g.w = k
g.u = k
m.q = f
m.z = f
assert k.r.q.t.p.txt == "k"