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

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

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

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

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

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

h = A("h")
c = B("c")
d = C("d")
i = D("i")
g = E("g")
e = F("e")

h.v = d
c.s = i
c.q = i
c.x = d
c.o = g
c.r = h
d.y = c
i.v = h
i.y = g
g.z = d
g.y = e
e.q = d
e.s = i
assert d.y.s.v.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

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

h = A("h")
c = B("c")
d = C("d")
i = D("i")
g = E("g")
e = F("e")

h.v = d
c.s = i
c.q = i
c.x = d
c.o = g
c.r = h
d.y = c
i.v = h
i.y = g
g.z = d
g.y = e
e.q = d
e.s = i
assert d.y.s.v.v.y.txt == "c"