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

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

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

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

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

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

h = A("h")
a = B("a")
l = C("l")
d = D("d")
g = E("g")
i = F("i")

h.q = d
h.u = d
a.v = l
l.p = g
l.q = d
l.o = a
l.x = a
d.s = g
d.r = h
g.y = l
g.q = i
i.w = a
i.s = a
i.q = d
assert a.v.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: D = None
        self.txt = txt

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

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

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

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

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

h = A("h")
a = B("a")
l = C("l")
d = D("d")
g = E("g")
i = F("i")

h.q = d
h.u = d
a.v = l
l.p = g
l.q = d
l.o = a
l.x = a
d.s = g
d.r = h
g.y = l
g.q = i
i.w = a
i.s = a
i.q = d
assert a.v.p.q.txt == "i"