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

class B:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.o: D = None
        self.y: D = None
        self.p: D = None
        self.txt = txt

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

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

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

g = A("g")
k = B("k")
j = C("j")
m = D("m")
e = E("e")
c = F("c")

g.x = k
g.q = j
k.p = c
j.s = g
j.o = m
j.y = m
j.p = m
m.s = g
m.o = k
e.u = g
e.v = m
e.w = c
e.s = j
c.s = m
c.z = m
c.o = g
c.x = k
c.q = e
assert e.w.o.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.o: D = None
        self.y: D = None
        self.p: D = None
        self.txt = txt

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

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

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

g = A("g")
k = B("k")
j = C("j")
m = D("m")
e = E("e")
c = F("c")

g.x = k
g.q = j
k.p = c
j.s = g
j.o = m
j.y = m
j.p = m
m.s = g
m.o = k
e.u = g
e.v = m
e.w = c
e.s = j
c.s = m
c.z = m
c.o = g
c.x = k
c.q = e
assert e.w.o.q.o.txt == "m"