class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.u: D = None
        self.p: F = None
        self.t: F = None
        self.w: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.t: E = None
        self.v: A = None
        self.p: C = None
        self.q: F = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: C = None
        self.p: C = None
        self.txt = txt

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

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

a = A("a")
d = B("d")
n = C("n")
b = D("b")
j = E("j")
g = F("g")

a.x = g
a.p = g
a.t = g
a.w = g
a.u = b
d.x = j
d.t = j
d.v = a
d.p = n
d.q = g
n.p = g
n.u = g
n.r = d
b.x = n
b.v = n
b.p = n
j.p = g
g.r = n
assert j.p.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.u: D = None
        self.p: F = None
        self.t: F = None
        self.w: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: E = None
        self.t: E = None
        self.v: A = None
        self.p: C = None
        self.q: F = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: C = None
        self.p: C = None
        self.txt = txt

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

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

a = A("a")
d = B("d")
n = C("n")
b = D("b")
j = E("j")
g = F("g")

a.x = g
a.p = g
a.t = g
a.w = g
a.u = b
d.x = j
d.t = j
d.v = a
d.p = n
d.q = g
n.p = g
n.u = g
n.r = d
b.x = n
b.v = n
b.p = n
j.p = g
g.r = n
assert j.p.r.u.txt == "g"