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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: E = None
        self.t: E = None
        self.v: C = None
        self.w: D = None
        self.o: C = None
        self.txt = txt

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

i.u = h
h.q = i
b.x = e
b.u = i
b.v = g
d.p = e
d.w = h
e.r = d
e.q = g
e.z = i
g.s = e
g.t = e
g.v = b
g.o = b
g.w = d
assert d.w.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: E = None
        self.t: E = None
        self.v: C = None
        self.w: D = None
        self.o: C = None
        self.txt = txt

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

i.u = h
h.q = i
b.x = e
b.u = i
b.v = g
d.p = e
d.w = h
e.r = d
e.q = g
e.z = i
g.s = e
g.t = e
g.v = b
g.o = b
g.w = d
assert d.w.q.u.q.txt == "i"