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

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

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

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

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

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

j = A("j")
b = B("b")
d = C("d")
e = D("e")
n = E("n")
k = F("k")
m = B("m")

j.q = d
j.z = b
b.x = k
b.u = n
d.z = k
d.x = b
e.z = k
n.x = d
n.u = k
k.p = n
k.w = j
m.x = k
m.u = n
assert j.z.u.x.z.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.z: B = None
        self.txt = txt

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

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

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

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

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

j = A("j")
b = B("b")
d = C("d")
e = D("e")
n = E("n")
k = F("k")
m = B("m")

j.q = d
j.z = b
b.x = k
b.u = n
d.z = k
d.x = b
e.z = k
n.x = d
n.u = k
k.p = n
k.w = j
m.x = k
m.u = n
assert j.z.u.x.z.p.x.txt == "d"