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

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

class C:
    def __init__(self, txt: str):
        self.o: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.o: A = None
        self.t: D = None
        self.s: C = None
        self.z: C = None
        self.txt = txt

d = A("d")
i = B("i")
m = C("m")
h = D("h")
c = E("c")
l = F("l")
b = C("b")

d.q = b
i.v = c
i.o = d
i.s = h
m.o = l
h.q = i
c.v = h
l.x = m
l.z = m
l.o = d
l.t = h
l.s = b
b.o = l
assert i.s.q.v.v.q.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: F = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.x: C = None
        self.o: A = None
        self.t: D = None
        self.s: C = None
        self.z: C = None
        self.txt = txt

d = A("d")
i = B("i")
m = C("m")
h = D("h")
c = E("c")
l = F("l")
b = C("b")

d.q = b
i.v = c
i.o = d
i.s = h
m.o = l
h.q = i
c.v = h
l.x = m
l.z = m
l.o = d
l.t = h
l.s = b
b.o = l
assert i.s.q.v.v.q.o.q.txt == "b"