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

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

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.p: E = None
        self.t: E = 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.y: D = None
        self.r: A = None
        self.z: C = None
        self.txt = txt

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

d = A("d")
g = B("g")
a = C("a")
n = D("n")
h = E("h")
c = F("c")

d.u = c
g.v = h
g.q = c
g.o = d
a.x = n
a.p = h
a.t = h
n.q = g
h.y = n
h.r = d
h.z = a
c.s = d
c.o = h
c.w = h
c.x = g
assert c.w.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.p: E = None
        self.t: E = 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.y: D = None
        self.r: A = None
        self.z: C = None
        self.txt = txt

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

d = A("d")
g = B("g")
a = C("a")
n = D("n")
h = E("h")
c = F("c")

d.u = c
g.v = h
g.q = c
g.o = d
a.x = n
a.p = h
a.t = h
n.q = g
h.y = n
h.r = d
h.z = a
c.s = d
c.o = h
c.w = h
c.x = g
assert c.w.r.u.txt == "c"