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

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: F = None
        self.x: A = None
        self.u: A = None
        self.w: B = None
        self.v: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: A = None
        self.txt = txt

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

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

a.p = f
n.p = f
n.z = f
n.v = f
n.y = g
n.s = a
g.r = n
g.w = n
g.v = n
g.y = b
g.x = a
g.u = a
f.u = m
f.x = a
m.v = a
m.z = a
b.s = a
j.v = a
j.z = a
assert b.s.p.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: F = None
        self.x: A = None
        self.u: A = None
        self.w: B = None
        self.v: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: A = None
        self.txt = txt

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

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

a.p = f
n.p = f
n.z = f
n.v = f
n.y = g
n.s = a
g.r = n
g.w = n
g.v = n
g.y = b
g.x = a
g.u = a
f.u = m
f.x = a
m.v = a
m.z = a
b.s = a
j.v = a
j.z = a
assert b.s.p.x.p.x.txt == "a"