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

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.q: A = None
        self.r: C = None
        self.y: C = None
        self.p: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: E = None
        self.o: E = None
        self.x: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.txt = txt

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

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

h.r = b
h.z = d
k.z = g
k.q = h
k.r = m
k.y = m
k.p = d
m.v = d
m.o = d
m.x = h
g.z = b
g.y = h
d.v = b
b.s = g
b.y = k
assert m.x.z.v.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: F = None
        self.z: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.q: A = None
        self.r: C = None
        self.y: C = None
        self.p: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: E = None
        self.o: E = None
        self.x: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.txt = txt

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

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

h.r = b
h.z = d
k.z = g
k.q = h
k.r = m
k.y = m
k.p = d
m.v = d
m.o = d
m.x = h
g.z = b
g.y = h
d.v = b
b.s = g
b.y = k
assert m.x.z.v.s.y.txt == "h"