class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: B = None
        self.w: E = None
        self.q: D = None
        self.s: C = None
        self.v: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: D = None
        self.u: B = None
        self.v: D = None
        self.txt = txt

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

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

h.y = k
h.s = k
h.x = g
h.w = b
h.q = m
h.v = m
g.y = m
k.p = b
k.y = m
m.q = f
m.x = f
m.r = h
b.x = g
b.u = g
b.r = m
b.v = m
f.x = g
assert h.v.r.w.r.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: B = None
        self.w: E = None
        self.q: D = None
        self.s: C = None
        self.v: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: D = None
        self.u: B = None
        self.v: D = None
        self.txt = txt

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

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

h.y = k
h.s = k
h.x = g
h.w = b
h.q = m
h.v = m
g.y = m
k.p = b
k.y = m
m.q = f
m.x = f
m.r = h
b.x = g
b.u = g
b.r = m
b.v = m
f.x = g
assert h.v.r.w.r.q.x.txt == "g"